How to update variant product text with Liquid/HTML in VAT calculation?

How to update variant product text with Liquid/HTML in VAT calculation?

cdevlin
Shopify Partner
17 0 1

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 

Replies 3 (3)

gr_trading
Shopify Partner
2032 148 205

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.

For any custom development WhatsApp or connect at Email ID: support@grtrading.in for quick consultation. | Shopify Free codes
To support Buy Me a Coffee

BSS-Commerce
Shopify Partner
3477 464 552

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


BSS Commerce - Full-service eCommerce Agency
cdevlin
Shopify Partner
17 0 1

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.