Display dynamic product variant price in javascript variable on product page

Display dynamic product variant price in javascript variable on product page

product-airpay
Shopify Partner
5 0 1

Since liquid is a server side language I'm having difficulty getting the actual Product price when out of Multiple product variants one is chosen. Can anyone let me know how to get accurate price of Product variant when chosen  from multiple options respectively. Based on the product option the Product price needs to be given to javascript variable so that it can be used in client side.

Reply 1 (1)

tobebuilds
Shopify Partner
324 19 89

Why not just use Liquid to generate a JSON object containing all the variants?

 

You could use a for loop, and emit an array containing each variant's iD, title, price, and compare at price.