<?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();
$stocka = $product->get_stock_status();
$pr_id = get_the_ID();

?>

<div <?php wc_product_class('product product-new-one position-relative bg-white d-flex flex-column', $product); ?>>
    <?php if ($product->is_on_sale()): ?>
        <div class="offer d-flex flex-column position-absolute align-items-center justify-content-center">
            <i class="icon-discount-2 d-flex align-items-center justify-content-center"></i>
            <?php 
                $offer_percentage = kavehWoo::showofferpercentage($product);
                echo $offer_percentage;
            ?>
        </div>
    <?php endif; ?>
    <div class="image">
        <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" width="161" height="161" class="d-block mx-auto">
        </a>
    </div>
    <h2 class="title overflow-hidden">
        <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">
    <?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>