<?php

if ( ! get_theme_mod( 'cat_groomer_enable_service_section', false ) ) {
	return;
}

$cat_groomer_args = '';

cat_groomer_render_service_section( $cat_groomer_args );

/**
 * Render Service Section.
 */
function cat_groomer_render_service_section( $cat_groomer_args ) { ?>
		<section id="cat_groomer_trending_section" class="asterthemes-frontpage-section trending-section trending-style-1">
		<?php
		if ( is_customize_preview() ) :
			cat_groomer_section_link( 'cat_groomer_service_section' );
		endif;

		$cat_groomer_trending_product_heading = get_theme_mod( 'cat_groomer_trending_product_heading');
		?>
		<div class="asterthemes-wrapper">
			<?php if ( ! empty( $cat_groomer_trending_product_heading ) ) { ?>
				<div class="header-contact-inner">
					<h3><?php echo esc_html( $cat_groomer_trending_product_heading ); ?></h3>
				</div>
			<?php } ?>
			<?php $cat_groomer_catData = get_theme_mod('cat_groomer_trending_product_category','');
      if ( class_exists( 'WooCommerce' ) ) {
        $cat_groomer_args = array(
          'post_type' => 'product',
          'posts_per_page' => 100,
          'product_cat' => $cat_groomer_catData,
          'order' => 'ASC'
        );?>
        <div class="product-box"> 
	        <?php $cat_groomer_loop = new WP_Query( $cat_groomer_args );
	        while ( $cat_groomer_loop->have_posts() ) : $cat_groomer_loop->the_post(); global $product; ?>
	          <div class="tab-product wow zoomIn" data-wow-delay="0.5s" data-wow-duration="2s">
            	<figure>
              	<?php if (has_post_thumbnail( $cat_groomer_loop->post->ID )) echo get_the_post_thumbnail($cat_groomer_loop->post->ID, 'shop_catalog'); else echo '<img src="'.esc_url(wc_placeholder_img_src()).'" />'; ?>
              </figure>
        			<div class="product-content-box">
        				<h5 class="product-text"><a href="<?php echo esc_url(get_permalink( $cat_groomer_loop->post->ID )); ?>"><?php the_title(); ?></a></h5>
        				<div class="product-rating">
        					<span class="<?php echo esc_attr( apply_filters( 'woocommerce_product_price_class', 'price' ) ); ?>">
        						<?php echo $product->get_price_html(); ?></span>
        					<span class="rating-box">
        						<?php if( $product->is_type( 'simple' ) ){ woocommerce_template_loop_rating( $cat_groomer_loop->post, $product ); } ?>	
        					</span>
        				</div>
        			</div>
        			<div class="box-content intro-button">
              			<?php if( $product->is_type( 'simple' ) ) { woocommerce_template_loop_add_to_cart(  $cat_groomer_loop->post, $product );} ?>
          			</div>
	          </div>
	        <?php endwhile; wp_reset_postdata(); ?>
	      </div>
      <?php } ?>
		</div>
	</section>
	<?php
}