How can I make the variant price change on my product page?

How can I make the variant price change on my product page?

florchmr
Tourist
8 0 3

 

Hi, I want to use an automatic 50% discount on one of my products. I would like this discount to also be displayed on the product page, so I have been working on adding this Liquid code to my template:

 
<div class="price-edit"> <span class="original-price">{{ product.selected_or_first_available_variant.price | money_with_currency }}</span> <span class="discounted-price"> {{ product.selected_or_first_available_variant.price | times: 0.5 | money_with_currency }}</span> <span class="badge-sale-edit">Sale</span> </div>
 

Initially, it looks great, but the price does not update when I start selecting other variants. In this product, I have 3 different prices according to the selected variant.

 

How can I make it so that the price changes according to the variant? I am using the Dawn theme.

Replies 3 (3)

DitalTek
Shopify Partner
856 103 121

@florchmr 

Your code currently just applied for first variant, and you want to that discount will apply to all variant when you change options, right?

- You can please Like and Accepted Solution if my suggestion helpful.
- And you want to hire developer Theme or App Shopify => Feel free to send me a DM or contact to us via Email | WhatsApp
- Website: ditaltek.com
florchmr
Tourist
8 0 3

Hi! Yes, currently with that code, the original price and the discounted price only apply to the first variant. I want the prices to change as I select other variants.

DitalTek
Shopify Partner
856 103 121

To do that, you can apply that code for show other variants price, but instead of using first variant you need to handle with variant price other.

- You can please Like and Accepted Solution if my suggestion helpful.
- And you want to hire developer Theme or App Shopify => Feel free to send me a DM or contact to us via Email | WhatsApp
- Website: ditaltek.com