Search code examples
shopifyliquidshopify-template

Show variants prices on product page in specific place


I have a store with 10 products.

One of them is a subscription for a magazine, with 3 variants: 6 months, 1 year and 2 year

 

I made the product page with a custom template and i inserted the prices with simple html as so: 

Price: 25 $ and so on for the other variants...

Now i'm doing some promos so i would like to have the price updating without having to change it in the theme, i was trying something like that to make it work but without success:

{% assign semestraleid = '18773651783776' %}{% variant.id == semestraleid %} {{ current_variant.price | money }} {% if current_variant.compare_at_price > current_variant.price %} <s style="color: #B8DAEE; font-size: 0.85em;">{{ current_variant.compare_at_price | money }}</s> {% endif %} {% endif %}

So here is the question: HOW CAN I DISPLAY THE REAL PRICE OF EACH VARIANT IN THIS ONE-PAGE PRODUCT PAGE, EXACTLY WHERE I WANT WITH A CODE SNIPPET?

 

Thank you

PS: I've also tried doing some other experiments using the assign and split, i have succeded into printing the price of every variant all together, but after that i didn't know how to show the price correctly as i would like. 


Solution

  • Loop through each of the Product's Variants and output the price:

    {% for variant in product.variants %}
        {{ variant.price | money }}
    {% endfor %}
    

    ... or output each one separately using its index:

    {{ product.variants[0].price | money }}
    {{ product.variants[1].price | money }}
    {{ product.variants[2].price | money }}
    

    [index is zero-based]