<?php $kproduct = get_query_var('kproduct'); ?>
<?php $woo_currency = get_woocommerce_currency_symbol(); ?>
<div class="product product-thirteen product-thirteen-two position-relative bg-white radius-15 overflow-hidden">
<?php if($kproduct['kaveh_custom']['product_stock_status'] === 'outofstock'): ?>
<div class="status">
ناموجود
</div>
<?php endif; ?>
<?php if ( $kproduct['kaveh_custom']['is_on_sale'] === true ): ?>
<div class="discount position-absolute text-white rounded-circle text-center fw-bold">
<?php if($kproduct['kaveh_custom']['product_type'] === 'variable'): ?>
    <?php echo (int)(( ( (float)$kproduct['kaveh_custom']['min_regular_price'] - (float)$kproduct['kaveh_custom']['min_sale_price'] ) / (float)$kproduct['kaveh_custom']['min_regular_price'] ) * 100); ?><?php echo ' '.'%'; ?>
<?php elseif($kproduct['kaveh_custom']['product_type'] === 'simple'): ?>
    <?php echo (int)(( ( (float)$kproduct['kaveh_custom']['normal_price'] - (float)$kproduct['kaveh_custom']['sale_price'] ) / (float)$kproduct['kaveh_custom']['normal_price'] ) * 100); ?><?php echo ' '.'%'; ?>
<?php endif; ?>
</div>
<?php endif; ?>

<div class="product-image pt-0">
<?php if ( is_plugin_active( 'woo-smart-compare/wpc-smart-compare.php' ) ): ?>
<?php echo do_shortcode( '[woosc id="".<?php echo get_the_ID(); ?>.""]' );  ?>
<?php endif; ?>
<a href="<?php echo $kproduct['link'] ?>" class="d-block">
<img src="<?php echo $kproduct['kaveh_custom']['thumbnail_url'] ?>" alt="product" class="d-block w-100" />
</a>
<ul class="btns position-absolute">
<?php if(!empty($kproduct['kaveh_custom']['normal_price']) ): ?> 
    <?php if($kproduct['kaveh_custom']['product_type'] !== 'variable'): ?>
        <?php if($kproduct['kaveh_custom']['product_stock_status'] !== 'outofstock'): ?>
            <li>
                <a type="submit" name="add-to-cart" value="<?php echo $kproduct['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 endif; ?>
    <?php endif; ?>
<?php endif; ?>
<li>
    <a id="eyeid" type="button" value="<?php echo $kproduct['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>
<li>
    <a href="#" class="rounded-circle text-center d-block">
        <?php if ( is_plugin_active( 'woo-smart-wishlist/wpc-smart-wishlist.php' ) ): ?>
        <?php echo do_shortcode( '[woosw id="".<?php echo get_the_ID(); ?>.""]' ); ?>
        <?php endif; ?>
    </a>
</li>
</ul>
</div>
<div class="detail p-0">
<h2 class="text-center mt-0">
<a href="<?php echo $kproduct['link'] ?>"><?php echo $kproduct['title']['rendered']; ?></a>
</h2>
<?php if($kproduct['kaveh_custom']['product_stock_status'] !== 'outofstock'): ?>
<?php if($kproduct['kaveh_custom']['product_type'] !== 'variable'): ?>
<div class="price text-center">
<?php if(!empty($kproduct['kaveh_custom']['normal_price'])): ?>
<?php echo number_format($kproduct['kaveh_custom']['normal_price'], 0, '.', ','); ?>
<?php endif; ?> 
<span> <?php echo $woo_currency; ?></span>
</div>
<?php else: ?>
<div class="price text-center">
<?php if($kproduct['kaveh_custom']['min_regular_price'] !== $kproduct['kaveh_custom']['max_regular_price']): ?>
    <?php if(!empty($kproduct['kaveh_custom']['min_regular_price'])): ?>
    <?php echo number_format($kproduct['kaveh_custom']['min_regular_price'], 0, '.', ',') . ' - ' . number_format($kproduct['kaveh_custom']['max_regular_price'], 0, '.', ',') . ' '; ?>
<?php endif; ?>
<?php else: ?>
    <?php if(!empty($kproduct['kaveh_custom']['min_regular_price'])): ?>
    <?php echo number_format($kproduct['kaveh_custom']['min_regular_price'], 0, '.', ',')  . ' '; ?>
<?php endif; ?>
<?php endif; ?> 
<span> <?php echo $woo_currency; ?></span>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
</div>