Debut - Variant show lowest price without "Compare" variants

Highlighted
New Member
2 0 0

So there's tons of posts about showing lowest price instead of highest price. However, I have four Variants for a product and one of those variants displays "Compare at price" because it's a sale item.

 

On my Collections Page I want to display the lowest priced variant. But instead it's showing the highest price and also showing the striked out "Compare at price" variant.

 

How do I manipulate my liquid code to show the lowest price without the "Compare at price"? Thanks!

0 Likes
Highlighted
New Member
2 0 0

Here is my liquid code - if I change the "variant.price_max" to "variant.price_min" - I will still see the strikethru price and the word "sale"

 

<!-- snippet/product-price.liquid -->
{% if variant.title %}
  {%- assign compare_at_price = variant.compare_at_price -%}
   {% if variant.price_max %}
    {%- assign price = variant.price_max -%}   
{% else %}
 {%- assign price = variant.price -%}
{% endif %}
  {%- assign available = variant.available -%}
{% else %}
  {%- assign compare_at_price = 1999 -%}
  {%- assign price = 1999 -%}
  {%- assign available = true -%}
{% endif %}
 
{%- assign money_price = price | money -%}
 
<dl class="price{% if compare_at_price > price %} price--on-sale{% endif %}" data-price>
 
  {% if section.settings.show_vendor %}
    <div class="price__vendor">
      <dt>
        <span class="visually-hidden">{{ 'products.product.vendor' | t }}</span>
      </dt>
      <dd>
        {{ product.vendor }}
      </dd>
    </div>
  {% endif %}
 
  <div class="price__regular">
    <dt>
      <span class="visually-hidden visually-hidden--inline">{{ 'products.product.regular_price' | t }}</span>
    </dt>
    <dd>
      <span class="price-item price-item--regular" data-regular-price>
        {% if available %}
          {% if compare_at_price > price %}
            {{ compare_at_price | money }}
          {% else %}
            {{ money_price }}
          {% endif %}
        {% else %}
          {{ 'products.product.sold_out' | t }}
        {% endif %}
      </span>
    </dd>
  </div>
  <div class="price__sale">
    <dt>
      <span class="visually-hidden visually-hidden--inline">{{ 'products.product.sale_price' | t }}</span>
    </dt>
    <dd>
      <span class="price-item price-item--sale" data-sale-price>
        {{ money_price }}
      </span>
      <span class="price-item__label" aria-hidden="true">{{ 'products.product.on_sale' | t }}</span>
    </dd>
  </div>
</dl>
 
0 Likes