<?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')).';';
            }
            if( get_theme_mod('fcatproduct_leftpadding',true) ) {
                $fcatproduct_leftpadding = 'padding-left:'.esc_attr(get_theme_mod('fcatproduct_leftpadding')).';';
            }
            if( get_theme_mod('fcatproduct_rightpadding',true) ) {
                $fcatproduct_rightpadding = 'padding-right:'.esc_attr(get_theme_mod('fcatproduct_rightpadding')).';';
            }
    ?>
<section id="fcatproduct-section" class="ht-section fcatproduct-section" style="<?php echo esc_attr($fcatproduct_toppadding); ?>" "<?php echo esc_attr($fcatproduct_bottompadding); ?>" "<?php echo esc_attr($fcatproduct_leftpadding); ?>" "<?php echo esc_attr($fcatproduct_rightpadding); ?>">

        <div class="container">
            <?php
                // echo "post id: ". 
                $lz_fitness_fcatproduct_page_id = get_theme_mod('lz_fitness_fcatproduct_page');
            // echo '<br>title '.
                $lz_fitness_fcatproduct_title = get_theme_mod('lz_fitness_fcatproduct_title', 'Fashion');               
             ?>
             <div class="ht-section-title-tagline">
                <h2 class="ht-section-title"><?php echo !empty($lz_fitness_fcatproduct_title)?$lz_fitness_fcatproduct_title:''; ?></h2>
            </div>
            <div class="clearfix"></div>

           
            <div class="col-md-9 padding0">

            <div class="responsive-tabs">			
                <?php
                $categories = get_theme_mod('lz_fitness_fcatproduct_categories');
                $args = array(
                    'number' => 12,
                    '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)){
                            ?>
                            <!-- <h2><?php //echo !empty($cat->name)?$cat->name:''; ?></h2> -->
                            <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; ?>		

                                    <?php 
                                        if( get_theme_mod('fproduct_height',true) ) {
                                            $fproduct_height = 'height:'.esc_attr(get_theme_mod('fproduct_height')).';';
                                        }
                                    ?>  							
                                    <div class="col-md-3 col-sm-3 padding0 fcatspace procatbord fcatpro wow zoomIn"  style="<?php echo esc_attr($fproduct_height); ?>"> 
                                        <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 class="clearfix"></div>
													
                                                </div>
                                            </div>
                                        </div>
                                    </div><!-- /span3 -->
                                <?php endwhile; 
                                wp_reset_query(); 
                                ?>
                                <div class="clearfix"></div>    
                            </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="col-md-3 fcatbanner padding0 wow fadeInRight">
                <?php
                    $static=true;
                    for($i=1;$i<2;$i++){
                        $link = get_theme_mod('fproduct_category_link'.$i);
                        $img = get_theme_mod('fproduct_category_image'.$i);
                        if (!empty($img) || !empty($link)){
                            $static=false;
                        }
                    }

                    if(function_exists('get_woocommerce_term_meta')){
                        for($i=1;$i<2;$i++){

                            if($static==false){
                                $link = get_theme_mod('fproduct_category_link'.$i);
                                $img = get_theme_mod('fproduct_category_image'.$i);
                                $url = get_theme_mod('fproduct_catelauge_url_'.$i, '#');
                                $category = get_term_by( 'id', $link, 'product_cat' );

                                $img = !empty($img)?$img:get_template_directory_uri().'/images/fcatprobanner.jpg';

                                if( !empty($url) || !empty($category) ){
                                    //echo $term->name;
                                    ?>
                                        <a href="<?php echo esc_url(!empty($url)?$url:'#');?>">
                                            <img src="<?php echo esc_url($img);?>" alt="">
                                        </a>
                                    <?php
                                }
                            }
                        }
                        //echo '<div class="clearfix"></div></div>';
                    }else{ ?>
                    <div class="alert alert-warning">
                        Kindly Install or Activate the WooCommerce plugin.
                    </div>
                    <?php }

                    if($static==true){
                        ?>
                            <a href="#">
                                <img class="img-responsive fcatproduct-img" src="<?php echo get_template_directory_uri(); ?>/images/fcatprobanner.jpg" alt="">
                            </a>
                        <?php
                    }?>
            </div>
          
</div>
     <div class="clearfix"></div>  
</section>

<?php }

