<?php
$product = wc_get_product(get_the_ID());
$sale_price = $product->get_sale_price();
$normal_price = $product->get_regular_price();
$options = kaveh_get_options();
$woo_currency = get_woocommerce_currency_symbol();
$min_regular_price = NULL;
$max_regular_price = NULL;
$min_sale_price = NULL;
$max_sale_price = NULL;
if ($product->is_type('variable')) {
    $min_regular_price = $product->get_variation_regular_price('min');
    $max_regular_price = $product->get_variation_regular_price('max');
    $min_sale_price = $product->get_variation_sale_price('min');
    $max_sale_price = $product->get_variation_sale_price('max');
}
$pr_id = get_the_ID();
$stocka = $product->get_stock_status();
?>
<div <?php wc_product_class('product product-thirteen product-thirteen-two position-relative bg-white radius-15 overflow-hidden', $product); ?>>
    <?php if ("instock" != $stocka) { ?>
        <div class="status">
            <?php esc_html_e('Out of Stock', 'kavehTheme'); ?>
        </div>
    <?php } ?>

    <?php if ($product->is_on_sale()): ?>
        <div class="discount position-absolute text-white rounded-circle text-center fw-bold">
            <?php if (class_exists('kavehWoo')) {
                $offer_percentage = kavehWoo::showofferpercentage($product);
                echo $offer_percentage;
            } ?>
        </div>
    <?php endif; ?>

    <div class="product-image pt-0">


        <a href="<?php the_permalink(); ?>" class="d-block">
            <img src="<?php if (get_the_post_thumbnail_url()): ?>
<?php the_post_thumbnail_url('full'); ?>
<?php else: ?>
<?php echo wc_placeholder_img_src(); ?>
<?php endif; ?>" alt="product" class="d-block w-100" />
        </a>
        <ul class="btns position-absolute">
            <?php
            if (!empty($normal_price)) {
                if (!$product->is_type('variable')) {
                    if ("instock" == $stocka) { ?>
                        <li>
                            <a type="submit" name="add-to-cart" value="<?php echo $pr_id ?>"
                                class="rounded-circle text-center d-block position-relative single_add_to_cart_button">
                                <i class="icon icon-cart-3"></i>
                            </a>
                        </li>
            <?php }
                }
            } ?>
            <li>
                <a id="eyeid" type="button" value="<?php echo $pr_id; ?>"
                    class="rounded-circle text-center d-block eyeid" data-bs-toggle="modal"
                    data-bs-target="#modal-product">
                    <i class="isax isax-eye3"></i>
                </a>
            </li>
                                                                     <?php if($options['kaveh_wishlist_system'] === '1'): ?>   

            <li>
                <?php echo do_shortcode('[wlm_button html_tag="a" class="rounded-circle text-center"]'); ?>
            </li>
                                    <?php endif; ?>

                        <?php if($options['kaveh_compare_system'] === '1'): ?>   

            <li>
                <?php echo do_shortcode('[compare_button id=' . get_the_ID() . ' background_color="#fff" color="#000" style="icon_only" radius="50" tag="a" class="rounded-circle text-center"]'); ?>
            </li>
                                      <?php endif; ?>


        </ul>
    </div>
    <div class="detail p-0">
        <h2 class="text-center mt-0">
            <a href="<?php the_permalink(); ?>">
              <?php
$title = get_the_title();
$show_full_titles = kaveh_get_option('kaveh_product_title_display', false);
if ($show_full_titles) {
    echo esc_html($title);
} else {
    if ( wp_is_mobile() ) {
        echo wp_trim_words( $title, 5, '...' );
    } else {
        echo wp_trim_words( $title, 8, '...' );
    }
}
?>
            </a>
        </h2>
        <div class="price mt-3">
            <?php
            // Use WooCommerce's built-in price HTML output
            $price_html = $product->get_price_html();
            // If we have price HTML (not empty)
            if ($price_html) {
                echo $price_html;
            }
            ?>
        </div>
    </div>
</div>