<?php
if ( ! get_theme_mod( 'jewelry_accessories_enable_product_section', false ) ) {
	return;
}

$jewelry_accessories_args = '';

jewelry_accessories_render_service_section( $jewelry_accessories_args );

/**
 * Render Product Section.
 */
function jewelry_accessories_render_service_section( $jewelry_accessories_args ) { ?>
		<section id="jewelry_accessories_trending_section" class="asterthemes-frontpage-section product-section trending-style-1">
		<?php
		if ( is_customize_preview() ) :
			jewelry_accessories_section_link( 'jewelry_accessories_service_section' );
		endif;

		$jewelry_accessories_trending_product_heading = get_theme_mod( 'jewelry_accessories_trending_product_heading');
		?>
		<div class="asterthemes-wrapper">
			<?php if ( ! empty( $jewelry_accessories_trending_product_heading ) ) { ?>
				<div class="header-contact-inner">
					<h3><?php echo esc_html( $jewelry_accessories_trending_product_heading ); ?></h3>
				</div>
			<?php } ?>
			<?php $jewelry_accessories_catData = get_theme_mod('jewelry_accessories_trending_product_category','');
			if ( class_exists( 'WooCommerce' ) ) {
				$jewelry_accessories_args = array(
				'post_type' => 'product',
				'posts_per_page' => -1,
				'product_cat' => $jewelry_accessories_catData,
				'order' => 'ASC'
				);?>
				<div class="product-box"> 
					<div class="owl-carousel">
						<?php $jewelry_accessories_loop = new WP_Query( $jewelry_accessories_args );
						while ( $jewelry_accessories_loop->have_posts() ) : $jewelry_accessories_loop->the_post(); global $product; ?>
							<div class="tab-product wow zoomIn delay-3000">
								<figure>
									<?php if (has_post_thumbnail( $jewelry_accessories_loop->post->ID )) echo get_the_post_thumbnail($jewelry_accessories_loop->post->ID, 'shop_catalog'); else echo '<img src="'.esc_url(wc_placeholder_img_src()).'" />'; ?>
								</figure>
								<div class="box-content intro-button addcart">
									<?php if( $product->is_type( 'simple' ) ) { woocommerce_template_loop_add_to_cart(  $jewelry_accessories_loop->post, $product );} ?>
								</div>
								<div class="product-content-box">
									<h5 class="product-text"><a href="<?php echo esc_url(get_permalink( $jewelry_accessories_loop->post->ID )); ?>"><?php the_title(); ?></a></h5>
									<div class="<?php echo esc_attr( apply_filters( 'woocommerce_product_price_class', 'price' ) ); ?>">
										<?php echo $product->get_price_html(); ?>
									</div>
								</div>
							</div>
						<?php endwhile; wp_reset_postdata(); ?>
					</div>
				</div>
			<?php } ?>
		</div>
	</section>
	<?php
}