<?php

/**
 * Slider template (style 3)
 *
 * @package storzen
 */

if (! defined('ABSPATH')) {
    exit;
}

if ($settings['style'] == 'style-3') :

?>
    <?php
    $storzen_slider_settings = [
        'loop'        => !empty($settings['loop']) && $settings['loop'] === 'yes',
        'enable_nav'  => !empty($settings['enable_nav']) && $settings['enable_nav'] === 'yes',
        'enable_dots' => !empty($settings['enable_dots']) && $settings['enable_dots'] === 'yes',
        'smart_speed' => isset($settings['smart_speed']['size']) ? (int) $settings['smart_speed']['size'] : 700,
        'items'       => isset($settings['items']['size']) ? (int) $settings['items']['size'] : 3,
        'margin'      => isset($settings['margin']['size']) ? (int) $settings['margin']['size'] : 30,
    ];
    ?>
    <!-- Shop Section Start -->
    <section class="shop-section fix section-padding pt-0">
        <div class="wco-container">
            <div class="swiper shop-slider2" data-slider-settings="<?php echo esc_attr(wp_json_encode($storzen_slider_settings)); ?>">
                <div class="swiper-wrapper">
                    <?php
                    if ($storzen_posts_query->have_posts()) :
                        while ($storzen_posts_query->have_posts()) : $storzen_posts_query->the_post();
                            $storzen_img_src = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
                            global $product;

                    ?>
                            <div class="swiper-slide">
                                <div class="shop-card-items mt-0">
                                    <div class="image">
                                        <div class="badges">
                                        <?php do_action( 'storzen_shop_card_badges', $product ); ?>
								</div>
                                        <?php the_post_thumbnail(); ?>
                                        <div class="social-style-two">
                                            <?php echo storzen_add_to_cart_button(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- storzen_add_to_cart_button() returns markup already escaped with esc_url/esc_attr/wc_implode_html_attributes. ?>
                                            <?php do_action( 'storzen_shop_card_overlay', $product ); ?>
                                        </div>
                                    </div>
                                    <div class="content">
                                        <?php
                                        $storzen_categories = get_the_terms(get_the_ID(), 'product_cat');
                                        if ($storzen_categories && !is_wp_error($storzen_categories)) :
                                            $storzen_category = array_shift($storzen_categories);
                                        ?>
                                            <a href="<?php echo esc_url(get_term_link($storzen_category)); ?>" class="category"><?php echo esc_html($storzen_category->name); ?></a>
                                        <?php endif; ?>
                                        <<?php echo esc_attr($settings['titltag']); ?>>
                                            <a <?php echo esc_attr(('new-window' == $settings['open-url'] ? 'target="_blank"' : '')); ?> href="<?php the_permalink(); ?>" class="woo-title">
                                                <?php
                                                if ('full' == $settings['dtitle']) :

                                                    the_title();

                                                else :
                                                    echo esc_html(wp_trim_words(get_the_title(), $settings['title_excerpt_length'], ''));
                                                endif;
                                                ?>
                                            </a>
                                        </<?php echo esc_attr($settings['titltag']); ?>>
                                        <div class="prices"><?php echo wp_kses_post($product->get_price_html()); ?></div>
								<?php do_action( 'storzen_shop_card_after_title', $product ); ?>
                                    </div>
                                </div>
                            </div>
                        <?php endwhile; ?>
                    <?php
                        wp_reset_postdata();
                    else :
                    ?>
                        <h3 class="no-post-found"><?php esc_html_e('Sorry, No Product Found', 'storzen') ?></h3>
                    <?php endif; ?>
                </div>
                <?php if (!empty($settings['enable_dots']) && $settings['enable_dots'] === 'yes') : ?>
                    <div class="swiper-dot2 text-center mt-5">
                        <div class="dot"></div>
                    </div>
                <?php endif; ?>
            </div>
            <?php if (!empty($settings['enable_nav']) && $settings['enable_nav'] === 'yes') : ?>
                <div class="array-button">
                    <button class="array-prev"><?php \Elementor\Icons_Manager::render_icon($settings['nav_left_icon'], ['aria_hidden' => 'true']); ?></button>
                    <button class="array-next"><?php \Elementor\Icons_Manager::render_icon($settings['nav_right_icon'], ['aria_hidden' => 'true']); ?></button>
                </div>
            <?php endif; ?>
        </div>
    </section>
<?php endif;
