How can I show number of variants available as well as the price range on them

ChazCGCChazCGC Member Posts: 5
edited March 7 in eCom

I'd like to have my products displayed like this item below, but If I carry this item on lightspeed in a matrix, people will only see one price and might be misled as to the price range and how many sizes we carry. How can I work around this?


3 comments

  • TradingboTradingbo Member Posts: 24

    I'd be curious to see a method for this as well support?

    The two previous comments appear to be off-topic to OPs question.

  • JoeyJoey Administrator, Moderator, Lightspeed Staff Posts: 197 moderator

    @Paula dat is een goeie vraag, neem aan dat je dit niet hier gepost hebt. 🤔

    @ChazCGC and @Tradingbo with theme editor enabled you can add the price range to the product page (not the collection pages) but it involves some creativity.

    You will need to look at the product.variant.price.price of all the variants and compare them to show the lowest and highest.

    This is how it can work:

    {% set minValue = 9999999 %}
    {% for variant in product.variants %}
     {% set minValue = min(variant.price.price, minValue) %}          
    {% endfor %}
    {{ minValue | money }}
     -
    {% set maxValue = 0 %}
    {% for variant in product.variants %}
     {% set maxValue = max(variant.price.price, maxValue) %}          
    {% endfor %}
    {{ maxValue | money }}
    

    Hope this is what you are looking for, unfortunately, this will not work on collections pages as the variant variables are not available.

    eCom Support Team
    Lightspeed HQ
  • TradingboTradingbo Member Posts: 24

    Hi Joey,

    Thanks for the response and the snippet.

    Is it possible the variant information will be made available on collections pages in the future? Seems like this would be useful for many developers/sites.

    I understand enabling the developer toolbar allows you to see which variables are available on any given page, but do you have a section in the documentation which lists which variables are available where?

    Seems to be nothing in https://ecom-support.lightspeedhq.com/hc/en-us/articles/115000277594-3-b-Rain-variables

    Thanks

Sign In or Register to comment.