<?php
$product = wc_get_product(get_the_ID());
$sale_price = $product->get_sale_price();
$normal_price = $product->get_regular_price();
$options = kaveh_get_options();

$pr_id = get_the_ID();
$stocka = $product->get_stock_status();
?>
<div <?php wc_product_class('product product-eleven overflow-hidden', $product); ?>>
  <div class="product-image">
                <?php if($options['kaveh_compare_system'] === '1'): ?>   

                    <?php echo do_shortcode('[compare_button id='. get_the_ID() .' style="icon_text" radius="50" tag="a" class="kaveh_compare_top"]'); ?>
                          <?php endif; ?>


    <?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">
        <?php if (class_exists('kavehWoo')) {
          $offer_percentage = kavehWoo::showofferpercentage($product);
          echo $offer_percentage;
        } ?>
      </div>
      <button type="button" class="bookmark btn btn-warning p-0 position-absolute">
        <i class="isax isax-ticket-discount5"></i>
      </button>
    <?php endif; ?>
    <ul class="colors position-absolute">
      <?php
      // Get the terms associated with the product
      
      $terms = get_the_terms($pr_id, 'pa_color');
      // Loop through the terms
      foreach ($terms as $term) {
        $val = get_term_meta($term->term_id, 'wpcvs_color', true) ?: '';
        $tooltip = get_term_meta($term->term_id, 'wpcvs_tooltip', true) ?: $term->name;
        ?>
        <li>
          <a href="<?php the_permalink(); ?>" class="rounded-circle d-block hint--right"
            aria-label="<?php echo esc_attr($tooltip) ?>" title="<?php echo esc_attr($tooltip) ?>"
            style="background-color: <?php echo esc_attr($val) ?>;"></a>
        </li>

        <?php
      }
      ?>
    </ul>
    <a href="<?php the_permalink(); ?>">
      <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">
    </a>
  </div>
  <div class="detail">
  <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>
    <h2>
      <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="btns d-flex align-items-center justify-content-center">
      <?php if (!$product->is_type('variable')) {
        if ("instock" == $stocka) { ?>
          <button type="button" class="add-to-cart single_add_to_cart_button position-relative cart11"
            value="<?php echo $pr_id; ?>">
            <i class="icon icon-cart-3"></i>
          </button>
        <?php }
      } ?>
                                                                           <?php if($options['kaveh_wishlist_system'] === '1'): ?>   

      <?php echo do_shortcode('[wlm_button html_tag="button" class="rounded-circle"]'); ?>
                                          <?php endif; ?>

      <button 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>
      </button>
      
    </div>
  </div>
</div>