<?php
/**
 *
 * @package Luzuk Premium
 */
if(get_theme_mod('furcatproduct_section_disable') != 'on' ){ ?>
     <?php 
            if( get_theme_mod('furcatproduct_toppadding',true) ) {
                $furcatproduct_toppadding = 'padding-top:'.esc_attr(get_theme_mod('furcatproduct_toppadding')).';';
            }
            if( get_theme_mod('furcatproduct_bottompadding',true) ) {
                $furcatproduct_bottompadding = 'padding-bottom:'.esc_attr(get_theme_mod('furcatproduct_bottompadding')).';';
            }
            
    ?>
<section id="furcatproduct-section" class="ht-section furcatproduct-section" style="<?php echo esc_attr($furcatproduct_toppadding); ?>" "<?php echo esc_attr($furcatproduct_bottompadding); ?>">
    <?php
        // echo "post id: ". 
        $lz_fitness_furcatproduct_page_id = get_theme_mod('lz_fitness_furcatproduct_page');
    // echo '<br>title '.
        $lz_fitness_furcatproduct_title = get_theme_mod('lz_fitness_furcatproduct_title', 'Category Product');               
     ?>
    <div class="ht-section-title-tagline">
        <h2 class="ht-section-title catproduct-title">
            <?php echo !empty($lz_fitness_furcatproduct_title)?$lz_fitness_furcatproduct_title:''; ?>
        </h2>
    </div>
    <div class="clearfix"></div>
    <div class="col-md-12 ">
        <div class="owl-carousel owl-theme">			
            <?php
                $categories = get_theme_mod('lz_fitness_furcatproduct_categories');
                $args = array(
                    'number' => 100,
                    'orderby' => 'name',
                    'order' => 'asc',
                    'hide_empty' => true,
                    'include' => $categories
                );
                $product_categories = get_terms('product_cat', $args);
                $i = 0;
                if(function_exists('get_woocommerce_term_meta')){
                    foreach ($product_categories as $cat) {
                        if(!empty($cat)){
            ?>           
            <?php
                $i = 0;
                $args = array( 'post_type' => 'product', 'posts_per_page' => 100,  'orderby' =>'date','order' => 'DESC' );
                if(!empty($cat->slug)){
                    $args['product_cat']= $cat->slug;
                }
                $product = new stdClass();
                $loop = new WP_Query( $args );
                while ( $loop->have_posts() ) : $loop->the_post();
                global $product; ?>	
              <?php 
               // if( get_theme_mod('furproduct_height',true) ) {
                   // $furproduct_height = 'height:'.esc_attr(get_theme_mod('furproduct_height')).';';
               // }
            ?>  							
            <div id="<?php echo $cat->slug;?>" class="padding0 furcatspace ecatpro wow zoomIn" > 
                <div class="item procatbord1">
                    <div class="pro-img text-center">
                        <a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                            <?php
                                if (has_post_thumbnail( $loop->post->ID )) 
                                    echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); 
                                else
                                    echo '<img src="'.get_template_directory_uri().'/images/default.png" alt="Placeholder" width="100%" height="200px" />'; 
                            ?>
                        </a>
                        <div class="content-part">												
                            <a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                                <h3><?php echo wp_trim_words( get_the_title(), 2 ); ?></h3>
                            </a>
                            <div class="pro-cat">
                                <?php
                                // Get the categories for the current product
                                $product_cats = get_the_terms(get_the_ID(), 'product_cat');
                                if ($product_cats && !is_wp_error($product_cats)) {
                                    $cat_names = array();
                                    foreach ($product_cats as $product_cat) {
                                        $cat_names[] = $product_cat->name;
                                    }
                                    echo implode(', ', $cat_names);
                                }
                                ?>
                            </div>
                            <?php
                                if(method_exists($product, 'get_price_html')){
                                    ?>
                                    <p class="product-price-tickr"><?php echo $product->get_price_html(); ?></p>
                                    <?php
                                }
                            ?>
                        </div>
                    </div>
                </div>
            </div>
        <?php endwhile; 
        wp_reset_query(); 
        ?>
   <!--  </div> -->
    <?php
}
}
    }else{?>
    <div class="alert alert-warning text-center">
        Kindly Install or Activate the WooCommerce plugin.
    </div>
    <?php
}
?>
</div>
</div>
<!-- </div> -->
     <div class="clearfix"></div>  
      <script>
  $(document).ready(function() {
    $('#furcatproduct-section .owl-carousel').owlCarousel({
      slideSpeed : 1500,
      autoplay: false,
      loop: true,
      margin: 30,
      responsiveClass: true,
      responsive: {
        0: {
          items: 2,
          nav: true,
          margin: 4
        },
        600: {
          items:3,
          nav: false
        },
        1000: {
          items:8,
          nav: true,
          loop: false,
          margin: 7
        }
      }
    })
  })
</script>
<script>
    jQuery.noConflict();
    $(function(){
        function procatbord1Height(){
            var ht = 0;
            $('#furcatproduct-section .procatbord1').each(function(i){
                var tHt = $(this).height();
                if(ht<tHt){
                    ht=tHt;
                }
            });
            $('#furcatproduct-section .procatbord1').height(ht+'px');
        }
        procatbord1Height();
    });
    $( window ).resize(function(){
        procatbord1Height();
    });
</script>
     
</section>
<?php }

