Show Compare At Price of First Variant on Collection Page- Lowest Compare Price Solution - MAINGATE

Show Compare At Price of First Variant, so the lowest compare price is shown.

First Use

This technique was first used on the Maingate Stores (PBRSHOP)

https://pbrshop.com/collections/sale-merchandise?page=4

Why Use This Technique

The client wanted to display the lowest compare price. They t-shirt had the small variant comparepriced at $35, but the XL variant compareprice was $40. They wanted to display the $35 price. Shopify's liquid displays the highest compare price and there isn't liquid to display the lowest compare price.

The solution.

Capture the compare at price of the first variant.

If the first variant has a compare price display it, if not display as normal.

The Code.

Open product-loop.liquid find the code that displays the was price. Will most likely look like {{ was | strip }}
{% capture compare_price_first_variant %}
    {{ product-loop.variants[0].compare_at_price | money }}
{% endcapture %}

{% if compare_price_first_variant != blank %}
    <small class="text-muted">Original: <del>{{ compare_price_first_variant }}</del></small>&nbsp;
{% else %}
    <small class="text-muted">Original: <del>{{ was | strip }}</del></small>&nbsp;
{% endif %}

Leave a comment