Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
HI,
I have added extra Liquid/HTML code to calculate a VAT (tax) and per unit price by multiplying the product price by a meta field value.
The issue I have is on variant products this value stays the same when a new variant is selected. The standard selling price does update but I'm guessing this is because it will have some magic Javascript trickery going on.
I am fairly confident with using Liquid and HTML etc, javascript though it is taking some learning!
Any help is appreciated.
Thanks, Christopher.
Store URL: www.insulationmerchant.com
Hey @cdevlin ,
Yes, you are right.
On selection of variant price of the single unit got change, therefore your calculation gave the wrong result.
Solution:
Whenever your product has variants create your metafield at the variant level and make it available as an attribute of the variant.
Write a script for clicking variant pills or dropdown to retrieve the value of metafield and perform your calculation with the retrieved value.
Hi @cdevlin
For this case, you can add a "click" event with JS code for Variants to display VAT again.
There are several docs you can refer to:
- https://shopify.dev/docs/api/liquid/objects/product, - https://shopify.dev/docs/api/liquid/objects/variant,
- https://shopify .dev/docs/api/liquid/objects/tax_line
I hope this is helpful to you.
If our suggestions are useful, please let us know by giving it a like, marking it as a solution, or donating here ☕.
B2B Solution & Custom Pricing | Product Labels by BSS
Need help from our expert? Kindly share your request with us via community@bsscommerce.com
Thanks, and sorry for the late reply!
This was what I assumed I would need to do. Javascript is where I have little experience so are their any tutorials or suggestions as to where I can learn how to do this best?
Thank you.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025