<?php
/**
 * Template part for displaying product section
 *
 * @package Carpenter Workshop
 * @subpackage carpenter_workshop
 */

?>
<?php if( get_theme_mod( 'carpenter_workshop_show_hide_product_section', true) != '') { ?>
<section id="product" class="py-5">
  <div class="product-top">
    <div class="container">
        <?php if(class_exists('woocommerce')){ ?> 
          <div class="product_kit">
            <div class="owl-carousel">
              <?php
                $carpenter_workshop_args = array(
                  'post_type'      => 'product',
                  'posts_per_page' => 10,
                  'product_cat'    => get_theme_mod('carpenter_workshop_recent_product_category')
                );
                $loop = new WP_Query( $carpenter_workshop_args );
                while ( $loop->have_posts() ) : $loop->the_post();
                ?>
                    <div class="product-box text-center m-1">
                      <?php global $product; ?>
                        <div class="product-image">
                          <?php echo woocommerce_get_product_thumbnail(); ?>
                          <?php carpenter_workshop_ts_show_sale_percentage(); ?>
                        </div>
                        <div class="product-content mt-2 px-2">
                            <h2><a href="<?php the_permalink(); ?>"><?php echo esc_html(get_the_title()); ?></a></h2>
                        </div>
                    </div>
                  <?php
                  endwhile;
                  wp_reset_query();
                ?>
            </div>
          </div>
        <?php }?>
    </div>
  </div>
</section>
<?php }?>