<?php
/** 
* @package LZ Restaurant Premium
*/
if(get_theme_mod('lz_fitness_featured_section_disable') != 'on' ){
wp_enqueue_script('slider', get_template_directory_uri().'/js/slider.js', array(), '1.1', true);
?>

 <?php 
            if( get_theme_mod('sectionproduct_toppadding',true) ) {
                $sectionproduct_toppadding = 'padding-top:'.esc_attr(get_theme_mod('sectionproduct_toppadding')).';';
            }
            if( get_theme_mod('sectionproduct_bottompadding',true) ) {
                $sectionproduct_bottompadding = 'padding-bottom:'.esc_attr(get_theme_mod('sectionproduct_bottompadding')).';';
            }
            if( get_theme_mod('sectionproduct_leftpadding',true) ) {
                $sectionproduct_leftpadding = 'padding-left:'.esc_attr(get_theme_mod('sectionproduct_leftpadding')).';';
            }
            if( get_theme_mod('sectionproduct_rightpadding',true) ) {
                $sectionproduct_rightpadding = 'padding-right:'.esc_attr(get_theme_mod('sectionproduct_rightpadding')).';';
            }
    ?>   
<section id="featured-post-section" class="ht-section"  style="<?php echo esc_attr($sectionproduct_toppadding); ?>" "<?php echo esc_attr($sectionproduct_bottompadding); ?>" "<?php echo esc_attr($sectionproduct_leftpadding); ?>" "<?php echo esc_attr($sectionproduct_rightpadding); ?>">
	
<div class="container">
<div class="wow fadeInUp" data-wow-duration="1s">
	<?php
	$showStatic = true;
	for( $i = 1; $i < 4; $i++ ){
		$lz_fitness_featured_page_id = get_theme_mod('lz_fitness_featured_page'.$i); 
		if(!empty($lz_fitness_featured_page_id)){
			$showStatic = false;
			break;
		}
	}
	$lz_fitness_featured_sub_title = get_theme_mod('lz_fitness_featured_sub_title', 'Best of Photos');
	$lz_fitness_featured_title = get_theme_mod('lz_fitness_featured_title', 'Feature Products');				
	
	?>
	<div class="row">
					<div class="ht-section-title-tagline">
						<div class="ht-section-tagline lz-featured-text">
							<?php if($lz_fitness_featured_sub_title){
								echo esc_html($lz_fitness_featured_sub_title);
							}?>
						</div>
						<h2 class="ht-section-title lz-featured-heading">
							<?php
							if(!empty($lz_fitness_featured_title))	{
								echo esc_html($lz_fitness_featured_title);
							} ?>
						</h2>
					</div>
					<div class="clearfix"></div>
				</div>
	<div class="row">
		<button class="slide-prev ctrl-btn pro-prev fa fa-caret-left"></button>
		<button class="ctrl-btn pro-next fa fa-caret-right slide-next"></button>
		<!-- Wrapper for slides -->
		<div class="slider" id="slider">
			<div class="slides" id="slide">
	    <!-- <div class="row-fluid">
	    	<div class="recent-box">-->
	    		<?php
	    		if(function_exists('woocommerce_template_loop_add_to_cart') && function_exists('WC')){
	    			$args = array( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => 4, 'orderby' =>'date','order' => 'DESC' );
	    			$meta_query   = WC()->query->get_meta_query();
	    			$tax_query   = WC()->query->get_tax_query();
	    			$tax_query[] = array(
	    				'taxonomy' => 'product_visibility',
	    				'field'    => 'name',
	    				'terms'    => 'featured',
	    				'operator' => 'IN',
	    			);
	    			$args = array(
	    				'post_type'   =>  'product',
	    				'stock'       =>  1,
	    				'posts_per_page' => -1, 
	    				'orderby'     =>  'date',
	    				'order'       =>  'DESC',
	    				'meta_query'  =>  $meta_query,
	    				'tax_query'   => $tax_query,
	    			);
	    			$loop = new WP_Query( $args );
	    			if($loop->post_count > 0){
	    				while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
	    					<div class="col-md-3 slide-item featured-product padding0"> 
	    						<div id="recent-porduct">
												<div class="pro-img text-center">
													<h3><?php the_title(); ?></h3>
													<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">
													</div>
												</div>
												<div class="pro-price text-center">
													<span class="price"><?php echo $product->get_price_html(); ?></span>
													<br>
													<div class="add-to-cart">
														<?php
														// woocommerce_template_loop_add_to_cart( $loop->single-product, $product );
														woocommerce_template_loop_add_to_cart();
														?>
													</div>												
													<div class="clearfix"></div>
												</div>
											</div>
	    						</div><!-- /span3 -->
	    						<?php
	    					endwhile; 
	    				}else{ ?>
	    					<div class="alert alert-warning text-center">
	    						<strong>Sorry, no featured products to show.</strong>
	    					</div>
	    					<?php
	    				}
	    				?>
	    				<!-- </div>-->
	    				<!-- </div>-->
	    				<?php
	    				wp_reset_query(); 
	    			}else{ ?>
	    				<div class="alert alert-warning text-center">
	    					Kindly Install or Activate the WooCommerce plugin.
	    				</div>
	    				<?php
	    			}?>
	    		</div>
	    	</div><!-- /row-fluid --> 
	    </div>
	</div>
</div>
<div class="clearfix"></div>
</section>

<?php } 
