<?php

/**
 * List one template
 *
 * @package storzen
 */

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

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

?>

    <!-- Shop Section Start -->
    <section class="shop-section fix section-padding pt-0">
        <div class="wco-container">
            <div class="wco-row wco-g-4">
                <div class="wco-col-xl-12">
                    <?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="shop-list-sidebar">
                                <div class="thumb" style="position:relative;">
                                    <div class="badges" style="position:absolute;top:8px;left:8px;z-index:2;">
                                        <?php do_action( 'storzen_shop_card_badges', $product ); ?>
                                    </div>
                                    <a href="<?php the_permalink(); ?>">
                                        <?php the_post_thumbnail(); ?>
                                    </a>
                                </div>
                                <div class="content">
                                    <div class="ratting">
                                        <?php
                                        $storzen_average = $product->get_average_rating();
                                        $storzen_full_stars = floor($storzen_average);
                                        $storzen_half_star = ($storzen_average - $storzen_full_stars) >= 0.5 ? 1 : 0;
                                        $storzen_empty_stars = 5 - $storzen_full_stars - $storzen_half_star;

                                        for ($storzen_i = 0; $storzen_i < $storzen_full_stars; $storzen_i++) {
                                            echo '<i class="fas fa-star rated"></i>';
                                        }
                                        if ($storzen_half_star) {
                                            echo '<i class="fas fa-star-half-alt rated"></i>';
                                        }
                                        for ($storzen_i = 0; $storzen_i < $storzen_empty_stars; $storzen_i++) {
                                            echo '<i class="fas fa-star"></i>';
                                        }
                                        ?>
                                    </div>
                                    <h6>
                                        <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>
                                    </h6>
                                    <div class="prices"><?php echo wp_kses_post($product->get_price_html()); ?></div>
								<?php do_action( 'storzen_shop_card_after_title', $product ); ?>
                                    <p><?php echo esc_html(wp_trim_words(get_the_excerpt(), 30, '...')); ?></p>
                                    <div class="cart-btns">
                                        <?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. ?>
                                        <div class="shop-icon">
                                            <?php do_action( 'storzen_shop_card_overlay', $product ); ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        <?php endwhile; ?>
                        <?php include storzen_get_template('pagination.php'); ?>
                    <?php
                        wp_reset_postdata();
                    else :
                    ?>
                        <h3 class="no-post-found"><?php esc_html_e('Sorry, No Product Found', 'storzen') ?></h3>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </section>

<?php endif;
