<?php
       
//faq
//team
/**
 * Use for the show the testimonials at home page and in testimonial page with shortcode
 * @param int $pageId default is null the id of a post
 * @param boolean $isCustomizer default is false if set to true it mean the output is set for the home page
 * @param int $i default null
 * @param boolean $showStaticVals default is false
 * @return string
 * @author Luzuk <support@luzuk.com>
 * */
/*services*/

    /**
     * Use for the show the testimonials at home page and in testimonial page with shortcode
     * @param int $pageId default is null the id of a post
     * @param boolean $isCustomizer default is false if set to true it mean the output is set for the home page
     * @param int $i default null
     * @param boolean $showStaticVals default is false
     * @return void
     * @author Luzuk <support@luzuk.com>
     * */
    function pricingShortcode() {
      ob_start();
      $cols = get_theme_mod('pricing_npp_count', 2);
      $cols++;
      switch ($cols) {
        case 1:
            $colCls = 'col-md-12 col-sm-12 col-xs-12';
            break;
            case 2: 
            $colCls = 'col-md-6 col-sm-6 col-xs-12';
            break;
            case 3:
            case 5:
            case 6:
            case 9:
            case 11:
            case 13:
            case 15:
            $colCls = 'col-md-4 col-sm-6 col-xs-12';
            break;
            default: 
            $colCls = 'col-md-6 col-sm-6 col-xs-12';
            break;
    }

    $showStatic = true;
    for ($i = 1; $i <= $cols; $i++) {
        $PlanPageId = get_theme_mod('pricing_plan_page_' . $i);
        $pricing_page_icon = get_theme_mod('pricing_plan_page_icon_'.$i);
        $planTitle  = get_theme_mod('pricing_plan_name_' . $i, 'Standard Plan');
        $planunit  = get_theme_mod('pricing_plan_unit_' . $i,'$');
        $planPrice  = get_theme_mod('pricing_plan_price_' . $i,'30');
        $planContent= get_theme_mod('pricing_plan_content_' . $i, '
            <p>Excepteur sint occaecat cupidatat non proi dent sunt in culpa.</p>
            <li>1 Bathroom Cleaning</li>
            <li>Up to 3 Bedrooms Cleaning</li>
            <li>1 Livingroom Cleaning</li>');

        $link = get_theme_mod('pricing_plan_url'.$i);
        $url = get_theme_mod('pricing_plan_url_'.$i, '#');

        if ($PlanPageId || $planTitle || $planunit || $planPrice || $planContent || $url || $pricing_page_icon) {
          $showStatic = false;
          ?>
          <div class="<?php echo $colCls; ?> pd-0">
            <div class="single-pricing wow bounceInUp">
            <div class="pr-s-area">
                <h4 class="plan-title inner-area-title" href="#">
                    <?php echo ($planTitle); ?>
                </h4>
                <div class="currency-price"><?php echo ($planunit); ?><?php echo ($planPrice); ?></div>
                <svg viewbox="0 0 100 25">
                    <path fill="#fff" d="M0 30 V19 Q30 28 50 20 T100 25 V30z" />
                </svg>
            </div>
            <ul class="pricing-list section-area-text wow slideInLeft"> <?php echo ($planContent); ?></ul>
            
            <?php
            $pricing_page_id = get_theme_mod('pricing_page');
            $pricing_page_button_title = get_theme_mod('pricing_page_button_title_'.$i, 'Select Plan');
            ?>
            <?php if($pricing_page_button_title){ ?>
                <div class="pc-btn wow zoomIn" data-wow-duration="4s">    
                    <a class="btn btn-lg" href="<?php echo esc_url(!empty($url)?$url:'#');?>" data-hover="/f178" >
                       <?php echo ($pricing_page_button_title);  ?>
                    </a>
                </div>
              

            <?php } ?>
            <!--  <div class="clearfix"></div> -->
        </div>
    </div>
    <?php
}
}
if ($showStatic === true) {
  for ($i = 1; $i <= $cols; $i++) {
    $link = get_theme_mod('pricing_plan_url'.$i);
    $url = get_theme_mod('pricing_plan_url_'.$i, '#');

    ?>
    <div class="<?php echo $colCls; ?> plan">
      <div class="pricing-plans">

        <div class="price-box">
          <div class="price-bx">

            <div class="plan-cost">$30</div>
        </div>
        <div class="clearfix"></div>
        <h4 class="plan-title">STANDARD</h4>
        <div class="table-content">
        Excepteur sint occaecat cupidatat non proi dent sunt in culpa.
     </div>
     <div class="clearfix"></div>
     <div class="pri-table-link">
      <a class="btn" href="#">DETAILS</a>
  </div>
</div>
<!-- <div class="clearfix"></div> -->
</div>
</div>
<?php
}

}

$pricingHtml = ob_get_contents();
        // echo $pricingHtml;
ob_flush();
ob_clean();
}



/**
 * Get list of all categories from woocommerce theme
 * @param int $isObject return type in array of object default is true
 * @param int $itemPerPagenumber of items per page default -1
 * @param int $isParents to show the only parents default '0'
 * @param int $orderby name of field ordeing with default 'name'
 * @param int $order assending of deseinging default 'ASC'
 * @param int $hideEmpty show the empty categories or not default 'false'
 * @return Array/Object 
 * @author Luzuk 
 * @since version 1.0
 **/
function getWooCategories($isObject = true, $id=0, $isParents = 0, $itemPerPagenumber = -1, $orderby='name', $order='ASC', $hideEmpty = false){
    $categories = array();
    // echo 'asdlkfjoasdoh';
    $args = array(
        'taxonomy' => 'product_cat',
        'orderby' => $orderby, // 'slug',
        'hide_empty' => $hideEmpty,
        'number'=> 0
    );

    if($isParents == 0 ){
        $args['parent'] = $isParents;
    }

    if(!empty($id) && $id >0 ){
        $args['term_taxonomy_id'] = $id;
    }
    $parent_terms = get_terms($args);
    // print_r($parent_terms);
    foreach ($parent_terms as $pterm) {
        if($isObject === true){
            $categories[] = $pterm;
        }elseif(!empty($pterm->term_id)){
            $categories[$pterm->term_id] = $pterm->name;
            // echo '&*&*&';
        }
        
    }
    // print_r($categories);
    return $categories;
}   
