<?php
global $product;
$sale_price = $product->get_sale_price();
$normal_price = $product->get_regular_price();

$pr_id = get_the_ID();
$stocka = $product->get_stock_status();
?>

<div <?php wc_product_class( '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 if (class_exists('kavehWoo')) { $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 the_post_thumbnail_url('medium'); ?>" alt="product" width="161" height="161"
class="d-block mx-auto">
</a>
</div>
<h2 class="title overflow-hidden">
<a href="<?php the_permalink(); ?>">  <?php the_title(); ?>  </a>
</h2>
<div class="d-flex align-items-center justify-content-between mt-auto">

<?php  if ( $product->is_type( 'variable' ) ): ?>
<div class="offer-price">
<div class="price">
<span> <?php $price_v = $product->get_price_html();
echo str_replace("&ndash;","<span class=\"dashvar\"> – </span>", $price_v); ?> </span>
<?php echo get_woocommerce_currency_symbol(); ?>
</div>
</div>
<?php else: ?>
<?php  if(!empty($sale_price) ): ?>
    <?php if(empty($sale_price) && empty($normal_price)) { ?>
<?php
$price_v = $product->get_price_html(); ?>
<div><?php
echo str_replace("&ndash;","<span class=\"dashvar\"> – </span>", $price_v); ?>
</div><?php
?>
<?php } ?>
<div class="offer-price">
<del> <?php echo number_format($normal_price, 0, '.', ','); ?> </del>
<div class="price">
<span> <?php echo number_format($sale_price, 0, '.', ','); ?> </span>
<?php echo get_woocommerce_currency_symbol(); ?>
</div>
</div>
<?php else: ?>
<div class="offer-price">
<div class="price">
<span> <?php echo number_format($normal_price, 0, '.', ','); ?> </span>
<?php echo get_woocommerce_currency_symbol(); ?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<?php  if ( $product->is_type( 'variable' ) ): ?>
<a href="<?php the_permalink(); ?>"  class="add-to-cart d-flex align-items-center justify-content-center">
<i class="icon-shoppin-bag"></i>
</a>
<?php else: ?>
<a href="#" name="add-to-cart" value="<?php echo $pr_id ?>" class="add-to-cart d-flex align-items-center justify-content-center single_add_to_cart_button">
<i class="icon-shoppin-bag"></i>
</a>
<?php endif; ?>
</div>

</div>