How to display variant title of sales price on collection page?

Hi

I am trying to display variant title of the sales price on collection page.

I am editing the

product-price-listing.liquid

So far I have tried using below code:

  {% comment %} Show title of the current variant in price  {% endcomment %}
  {% if product.variants.size > 1 %}
  <div class="custom_variant_price-div"><span>Price for one </span>{{ variant.title }}</div>
  {% else %}
  <div><span>Price pr. unit.</span></div>
  {% endif %}
  {% comment %}  Show title of the current variant in price - end  {% endcomment %}

The problem I am facing is that

variant.title

is giving me the title of the first pre-selected variant of the product. I want to show the title of the variant that is used for the sales price/price being displayed on the collection page.

I see there is

variant.unit_price

Is there something like variant.unit_title?

1 Like

Hi @FileNumberDate ,

You were trying to do a short cut :grin: . The code does not know which variants do you want. Try the corrected code below instead

{% comment %} Show title of the current variant in price  {% endcomment %}
  {% if product.variants.size > 1 %}
{% assign variant = product.variants[0] %}
  Price for one {{ variant.title }}

  {% else %}
  Price pr. unit. {{variant.price | money }}

  {% endif %}
  {% comment %}  Show title of the current variant in price - end  {% endcomment %}

In this code, we use the code below to should the variant price of the first variant

{{variant.price | money }}
1 Like

Thanks a lot @made4Uo !

I see and understand what you did there :slightly_smiling_face:
The variant for my store setting was

product.variants[1]

My store (Debut theme) is set up to show single price on product page, which would be:

product.variants[0]

but “bulk discount” on collection page, which is

product.variants[1]

Wishing you a great day!