I can't seem to find any mention of one in the documentation - is there a CartThrob variable for the tax calculated against the shipping charge (when you have shipping set as taxable)?

I was able to find one that is the shipping rate plus the added tax:


But I have not been able to find one for the tax amount separately. Anyone know if it exists? And if so, what it is?


You might be able to try a {exp:cartthrob:cart_items_info} tag pair which loops through all the items in your cart.

They have {cart_shipping} and {cart_shipping:plus_tax} tags available.
So, you could work it out yourself using the Arithmetic tag.

{exp:cartthrob:arithmetic operator="-" num1="{cart_shipping:plus_tax} num2="{cart_shipping}"}`

Put it all together: (Limit by 1 so it only outputs once)

{exp:cartthrob:cart_items_info limit="1"}
  Shipping: {cart_shipping}<br />
  Shipping Tax: {exp:cartthrob:arithmetic operator="-" num1="{cart_shipping:plus_tax} num2="{cart_shipping}"}<br />
  Shipping Total: {cart_shipping:plus_tax}
  • Great example. This is the way that I would go about it too. CT is incredibly flexible but naturally can't provide a tag for everything but it does a great job in providing the tools for you to grab what you need easily enough one way or another. – Ian Apr 9 '13 at 12:37
  • Great thought. I tried it and ran into a problem. The arithmetic expression generates an error of illegal character '$' presumably because these tax variables automatically generate the currency symbol based on your settings, etc. and do so as they are parsed. Any idea if they can be accessed as raw numerical values so they can be used in an equation as you suggest? – Jean St-Amand Apr 9 '13 at 14:03
  • I can't test it right now, but I think you can either append :numeric or ` prefix=""` to the inner tags. So, {cart_shipping:numeric} or {cart_shipping prefix=""} (Not sure which one - if any - works in this situation) – Jason Varga Apr 9 '13 at 14:14
  • Found the solution for a simple equation. Used the num1, num2 and operator params. Num1 and 2 strip out any non-numeric characters, so that solved it. Thanks once again Jason! – Jean St-Amand Apr 9 '13 at 14:21
  • Ha, I typed that method out first, then changed it because I thought expression="" was easier to read. I guess now we know the difference. I'll update the answer. – Jason Varga Apr 9 '13 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.