By default, the Debut theme shows the lowest variant price. I would like to show the max variant price on the collection featured products on the homepage and collection pages. I was able to change this on the individual product page by editing the product-price.liquid code but haven’t had any luck changing it on the collection grid. The URL is https://anaholagranola.com/
I changed a line of code to this but it only changed the product page
{%- assign price = product.price_max -%}
2
Answers
The theme seems to be displaying prices based off of a single variant being passed into the theme’s
product-price
snippet. It’s going to take a little bit more coding to update things to show the product’s max price.Here are two ideas for how you might do this:
current_variant
in yourfeatured-product
code.This might look something as follows:
Find:
Replace with:
{%- assign sorted_variant_list = product.variants | sort: ‘price’ | reverse -%}
{%- assign current_variant = sorted_variant_list.first -%}
This code will sort the variants by price (ascending by default) then reverses the order (so they should now be in descending price order) and then selects the first variant from that list, which should give you the highest-priced variant that will be fed into the
product-price
snippet.Create a new file in your theme’s
snippets
folder and give it a catchy name.Using the existing
product-price
file as a template, we might get something like this:I created the above by simply removing the
variant
pieces from the pricing snippet. To use this revised snippet you will need to pass inprice
,compare_at_price
andavailable
values. (Change ‘product-price-revised’ to whatever you called the snippet file that you created)In Debut Theme Snippets ->
product-card-grid.liquid
Replace:
{% include 'product-price', variant: product.selected_or_first_available_variant %}
With:
{% include 'product-price', variant: product %}
Then in the Snippet ->
product-price.liquid
Replace:
{%- assign price = variant.price -%}
With:
{%- assign price = variant.price_max -%}
I tested it on the Debut theme its working. You may also try this.