<?php
/**
 *
 * @package Luzuk Premium
 */
if(get_theme_mod('fcatproduct_section_disable') != 'on' ){ ?>
<?php 
    if( get_theme_mod('fcatproduct_toppadding',true) ) {
        $fcatproduct_toppadding = 'padding-top:'.esc_attr(get_theme_mod('fcatproduct_toppadding')).';';
    }
    if( get_theme_mod('fcatproduct_bottompadding',true) ) {
        $fcatproduct_bottompadding = 'padding-bottom:'.esc_attr(get_theme_mod('fcatproduct_bottompadding')).';';
    }            
?>
<section id="fcatproduct-section" class="ht-section fcatproduct-section" style="<?php echo esc_attr($fcatproduct_toppadding); ?>" "<?php echo esc_attr($fcatproduct_bottompadding); ?>">
    <?php
        $lz_fitness_fcatproduct_page_id = get_theme_mod('lz_fitness_fcatproduct_page');
        $lz_fitness_fcatproduct_title = get_theme_mod('lz_fitness_fcatproduct_title', 'Apparels & Colthings');      
    ?>
    <div class="row">
        <?php if( $lz_fitness_fcatproduct_title){ ?>
            <div class="ht-section-title-tagline">
                <h2 class="ht-section-title fcatproduct-heading">
                   <?php echo ($lz_fitness_fcatproduct_title);?>
                </h2>
            </div>
        <?php }?>
        <div class="clearfix"></div>
    </div>
    <div class="col-md-12">
        <div class="responsive-tabs">			
            <?php
                $categories = get_theme_mod('lz_fitness_fcatproduct_categories');
                $args = array(
                    'number' => 8,
                    'orderby' => 'name',
                    'order' => 'asc',
                    'hide_empty' => false,
                    '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)){
                    ?>
                        <div id="<?php echo $cat->slug;?>">
                            <?php
                                $i = 0;
                                $args = array( 'post_type' => 'product', 'posts_per_page' => 8,  '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; 
                            ?>					
                            <div class="col-md-3 col-sm-3 fcatspace procatbord fcatpro wow zoomIn"  > 
                                <div id="recent-porduct">
                                    <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 the_title(); ?></h3>  
                                            </a>
                                            <?php
                                                if(method_exists($product, 'get_price_html')){
                                                    ?>
                                                    <span class="price"><?php echo $product->get_price_html(); ?></span>
                                                    <?php
                                                }
                                            ?>
                                        </div>
                                    </div>
                                </div>
                            </div><!-- /span3 -->
                        <?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 class="clearfix"></div>
    </div>
</div>
<div class="clearfix"></div>  
</section>
<script>
    jQuery.noConflict();
    $(function(){
        function proimgHeight(){
            var ht = 0;
            $('#fcatproduct-section .pro-img').each(function(i){
                var tHt = $(this).height();
                if(ht<tHt){
                    ht=tHt;
                }
            });
            $('#fcatproduct-section .pro-img').height(ht+'px');
        }
        proimgHeight();
    });
    $( window ).resize(function(){
        proimgHeight();
    });
</script>
<?php }

