<?php if(class_exists('WooCommerce')):?>
<!-- Product  Start -->
<div class="home-section space section-products-latest">
	<div class="container">
		<div class="section-heading">
			<h2 class="section-title"><?php esc_html_e('Latest Products','storez') ?></h2>
		</div>
		<div class="clear"></div>
		<div class="section-content row woocommerce">
			<div class="home-products-recents col-12 order-last owl-carousel">
				<?php
					$product_count = absint(get_theme_mod('storez_home_recent_product_count', 15));
					$query_args = array( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => $product_count, 'orderby' =>'date','order' => 'DESC' );
					$products = new WP_Query( $query_args );
					$catorgies = array();
					while($products->have_posts()){
						$products->the_post();
						$cats = get_the_terms(get_the_ID(), 'product_cat');
						if($cats){
							foreach ($cats as $key => $acat) {
								$catorgies[$acat->slug] = $acat->name;
							}
						}
						wc_get_template( 'content-product-home-carousel.php');
					}
					wp_reset_postdata();
				?>
			</div>
			<?php if($catorgies): ?>
			<div class="cat-nav col-12 order-first">
				<button class="btn btn-theme btn-active btn-filter" data-filter="*"><?php esc_html_e('All', 'storez') ?></button>
				<?php 
					foreach($catorgies as $key => $category) {
						printf(' <button class="btn btn-theme btn-filter" data-filter="%1$s">%2$s</button>', esc_attr($key), esc_html($category));
					} 
				?>
			</div>			
		</div>
		<?php endif; ?>
	</div>
</div>
<!-- Product End -->
<?php endif; ?>