Only displaying price including tax when "Charge tax on this product" has been checked

andygosling
New Member
4 0 0

Hi,

On my site, I’m displaying the products’ price both with and without taxes:

img1.jpg

...using this code:

 

<p>{{ product.price | money }} <small>{{ product.price | times:1.2 | money }} inc. VAT</small></p>

 

However, there are a couple of items where tax is not charged (the "Charge tax on this product" option in the control panel is unchecked). Is there any way to only display the price including tax only on those items where tax is charged?

Something along these lines:

 

{% if tax_charged == true %}
<small>{{ product.price | times:1.2 | money }} inc. VAT</small>
{% endif %}

 

...but with legitimate Liquid. Are there any Liquid options for this sort of thing?

Many thanks,

Andy

Replies 3 (3)

LitExtension
Shopify Partner
4860 1001 1132

Hi @andygosling,

Please change the code:

{% if tax_charged == true %}
<small>{{ product.price | times:1.2 | money }} inc. VAT</small>
{% endif %}
=>
{% if tax_line.price != blank %}
<small>{{ product.price | times:1.2 | money }} inc. VAT</small>
{% endif %}

Hope it helps!

If my answer can help you solve your issue, please mark it as a solution. Thank you and good luck.

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
andygosling
New Member
4 0 0

Hi there,

Many thanks for your response. I tried your solution but unfortunately, it hid the price-with-tax for all products (including those ones tax is charged on).

I wasn’t aware of the tax_line object previously, so thank you for bringing it to my attention.

I tried adding {{ tax_line.rate }} and {{ tax_line.title }} to my code, just to see what the output would be, but it didn’t output anything at all, so I’m not sure what’s going on there!

Thanks again,

Andy

LitExtension
Shopify Partner
4860 1001 1132

Hi @andygosling,

You can refer https://help.shopify.com/en/manual/intro-to-shopify/initial-setup/sell-in-germany/price-per-unit

Or https://github.com/Shopify/dawn/blob/main/sections/main-product.liquid#L90 . https://i.imgur.com/KtpiTdN.png 

Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify