Dynamically change pricelabel

Highlighted
New Member
1 0 0

Problem:
I have a webshop where a user can can select straps with the selected watch. Some straps have different prices than others which makes the product either more or less pricy. I want to dynamically change the price on the pricelabel at the top of the screen and the price displayed in the 'add to cart button'. However I cannot seem to  get that working. The price shown corrects itself when the page is refreshed. That is, because the selected_variant (shopify liquid code) reloads in the element AFTER the refresh. You can see how this works by clicking on this link: https://www.fromanteel-watches.com/collections/most-wanted/products/gs-0802-generations-day-date-blu... and choose the steel strap and refresh the page. The prices change in the button and on top AFTER refresh.

 

I don't know how to access price information of the selected variant in JavaScript. Does anyone know how to fix this issue?

0 Likes