<?php 
if(get_theme_mod('feature_products_section_disable') != 'on' ){
	?>

 <?php 
  if( get_theme_mod('featuredpro_toppadding',true) ) {
    $featuredpro_toppadding = 'padding-top:'.esc_attr(get_theme_mod('featuredpro_toppadding')).';';
  }
  if( get_theme_mod('featuredpro_bottompadding',true) ) {
    $featuredpro_bottompadding = 'padding-bottom:'.esc_attr(get_theme_mod('featuredpro_bottompadding')).';';
  }
 
  ?>

	
	<section id="featured-product-section" class="ht-section wow slideInUp">
		
		<div class="lightbox" style="<?php echo esc_attr($featuredpro_toppadding); ?>" "<?php echo esc_attr($featuredpro_bottompadding); ?>">
			<div class="container">

				<div class="featured-posts-box">
					
						<?php
						$showStatic = true;
						for( $i = 1; $i < 4; $i++ ){
							$luzuk_featured_page_id = get_theme_mod('luzuk_featured_page'.$i); 
							if(!empty($luzuk_featured_page_id)){
								$showStatic = false;
								break;
							}
						}
						?>


						<?php
						$featured_product_subttl = get_theme_mod('featured_product_subttl', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever.');
						$featured_product_title = get_theme_mod('featured_product_title', 'Our Products');	

						$lz_prodbutton_title = get_theme_mod('lz_prodbutton_title', 'BUY NOW');
						
						?>
						<div class="col-md-6 col-md-offset-3">
							<div class=" ht-section-title-tagline text-center">
								
								<?php if( $featured_product_title || $featured_product_subttl){ ?>
									<h2 class="ht-section-title lz-featpro-heading">
										<?php
										if(!empty($featured_product_title))  {
											echo ($featured_product_title);
										} ?>
									</h2> 							
								<div class="clearfix"></div>						
									<div class="featproduct-subheading"><?php echo ($featured_product_subttl); ?>
								</div>								
								<?php } ?>  
							</div>
						</div>
							<div class="clearfix"></div> 
						

						
						<div class="row pro-grid">
							<div class="owl-carousel owl-theme"> 
								<?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' => 12, 
										'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="item"> 
				<div class="product-grid">
					<div class="product-image">
					<a  href="<?php the_permalink(); ?>" id="id-<?php the_id(); ?>" 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 class="pic-1" src="'.get_template_directory_uri().'/images/default.png" alt="Placeholder" width="100%" height="200px" />'; ?>	
						</a>					
															
				</div>

					
				<div class="product-content text-center">				
				<h3><?php the_title(); ?></h3>
				<div class="clearfix"></div>
				<?php echo $product->get_price_html(); ?>
				
				<div class="clearfix"></div>
				
<?php 
//echo apply_filters( 'woocommerce_short_description', substr($post->post_excerpt, 0, 100) ) 
?> 

<a class="buynow" href="<?php $add_to_cart = do_shortcode('[add_to_cart_url id="'.$post->ID.'"]');
    echo $add_to_cart;
?>" class="more"><?php echo ($lz_prodbutton_title); ?></a>

<!-- <a class="buynow" id="id-<?php //the_id(); ?>" href="<?php //the_permalink(); ?>" title="<?php //the_title(); ?>"><?php //echo ($lz_prodbutton_title); ?></a> -->
			<div class="clearfix"></div>
	</div>
														
	<div class="clearfix"></div>
	</div>
</div><!-- /span3 -->
		<?php
			endwhile; 
		}else{ ?>
<div class="alert alert-warning text-center">
	<strong>Sorry, no featured products to show.</strong>
</div>
	<?php
	}
	?>
<?php
	wp_reset_query(); 
	}else{ ?>
<div class="alert alert-warning text-center">
	Kindly Install or Activate the WooCommerce plugin.
	</div>
	<?php
		}?>
	</div><!-- /row-fluid --> 
		</div>
		
		</div>
				</div>
				<div class="clearfix"></div>

			</div>
		</section>
		<script>
			$(document).ready(function() {
				$('section#featured-product-section .owl-carousel').owlCarousel({
					slideSpeed : 3000,
              	    autoplay: true,
					loop: true,
					margin: 30,
					responsiveClass: true,
					responsive: {
						0: {
							items: 1,
							nav: true
						},
						600: {
							items:2,
							nav: true
						},
						1000: {
							items:4,
							nav: true,
							loop: true,
							margin:30
						}
					}
				})
			})
		</script>
	<?php } 
