d
Topic
RohanShopify Member
Posts:
4
Last edited 11 days ago

Debut Theme: Display Product Variant Max Price Under Collection

Hello Everyone,

I would like the collection page to display product variant max price instead of minimum (by default) , so it shows the higher variant price.

Can someone please help me in this regard.

Thanks

i
Replies
Posts:
469
10 days ago

Hi Rohan,

You are looking to edit your Snippets / product-price.liquid and at the very top you will see that the variant.price is assigned to price which is the variable that will be shown as the price.

Instead of that you can use variant.max_price which is the max price of all variants.

{%- assign price = variant.price_max -%}

CAUTION: This will not display correctly with compare at prices etc. For that to work correctly with on sale items etc. you need a few more changes, ideally though you would make them where this snippet is being called and the product variable assigned to the snippet (that's where you should check which variant is the highest price and pass that entire variant object to the product-price snippet.

Hope this helps!

I turn coffee in to code - since 1998
RohanShopify Member
Posts:
4
6 days ago

Hi karl,

Thanks for your reply. I replaced the code:

{%- assign price = product.price -%} with

{%- assign price = variant.price_max -%}

but it didn't work. Attaching the Debut theme "product-price.liquid" code. I also want to display it correctly for sale varient items, so please guide me.

Thanks

Rohan

 

<!-- snippet/product-price.liquid -->
{% if product.title %}
  {%- assign compare_at_price = product.compare_at_price -%}
  {%- assign price = product.price -%}
  {%- assign price_varies = product.price_varies -%}
  {%- assign available = product.available -%}
{% else %}
  {%- assign compare_at_price = 1999 -%}
  {%- assign price = 1999 -%}
  {%- assign price_varies = false -%}
  {%- assign available = true -%}
{% endif %}

{%- assign money_price = price | money -%}

{% if compare_at_price > price %}
  {% if price_varies %}
    <span class="visually-hidden">{{ 'products.product.regular_price' | t }}</span>
    <s class="product-price__price">{{ compare_at_price | money }}</s>
    <span class="product-price__price product-price__sale">
      <span class="product__price">{{ money_price }}</span>
      <span class="product-price__sale-label">{{ 'products.product.on_sale' | t }}</span>
    </span>
  {% else %}
    <span class="visually-hidden">{{ 'products.product.regular_price' | t }}</span>
    <s class="product-price__price">{{ compare_at_price | money }}</s>
    <span class="product-price__price product-price__sale">
      {{ money_price }}
      <span class="product-price__sale-label">{{ 'products.product.on_sale' | t }}</span>
    </span>
  {% endif %}
{% else %}

  {% if price_varies %}
    <span class="product__price">{{ money_price }}</span>
  {% else %}
    <span class="visually-hidden">{{ 'products.product.regular_price' | t }}</span>
    <span class="product-price__price">{{ money_price }}</span>
  {% endif %}
{% endif %}

{% unless available %}
  <span class="product-price__sold-out">{{ 'products.product.sold_out' | t }}</span>
{% endunless %}