<?php 
/**
 * Template part for displaying Featured Product Section
 *
 * @package Kids Toy Center
 */

$kids_toy_center_about = get_theme_mod('kids_toy_center_about_setting', true);

if ($kids_toy_center_about) { ?>
    <div id="about-section" class="py-5">
        <div class="container">
            <?php
            $kids_toy_center_featured_mission_section_title = get_theme_mod('kids_toy_center_featured_mission_section_title');
            $kids_toy_center_featured_mission_section_short_title = get_theme_mod('kids_toy_center_featured_mission_section_short_title');
            ?>
            <div class="section-title mb-5 text-center">
                <?php if ($kids_toy_center_featured_mission_section_title) { ?>
                    <h3><?php echo esc_html($kids_toy_center_featured_mission_section_title); ?></h3>
                <?php } ?>
                <?php if ($kids_toy_center_featured_mission_section_short_title) { ?>
                    <p class="mb-3"><?php echo esc_html($kids_toy_center_featured_mission_section_short_title); ?></p>
                <?php } ?>
            </div>
            
            <?php if (class_exists('woocommerce')) { ?>
                <div class="product_kit">
                    <div class="owl-carousel">
                        <?php 
                        $kids_toy_center_args = array(
                            'post_type'           => 'product',
                            'posts_per_page'      => 10,
                            'product_cat' => get_theme_mod('kids_toy_center_product_category')
                        );
                        $i = 1;
                        $loop = new WP_Query($kids_toy_center_args);
                            while ($loop->have_posts()) : $loop->the_post(); 
                                global $product; ?>
                                <div class="align-self-center px-0">
                                    <div class="product-box <?php echo ('catebox-'.$i); ?> text-center m-1 wow zoomInUp delay-1000" data-wow-duration="2s">
                                        <div class="product-image">
                                            <?php echo woocommerce_get_product_thumbnail(); ?>
                                            <div class="pro-buttons">
                                                <div class="custom_product_meta">
                                                    <span class="mr-1 align-self-center">
                                                        <?php 
                                                        if ($product->is_type('simple')) { 
                                                            woocommerce_template_loop_add_to_cart($loop->post, $product); 
                                                        } 
                                                        ?>
                                                    </span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="product-content my-3">
                                            <h3><a href="<?php the_permalink(); ?>"><?php echo esc_html(get_the_title()); ?></a></h3>
                                        </div>
                                    </div>
                                </div>
                            <?php $i++; endwhile; 
                            wp_reset_postdata();
                        ?>
                    </div>
                </div>
            <?php } ?>
        </div>
    </div>
<?php } ?>