0

One of the changes in the CT 2.5 update is:

ADDED: exempt_discount_from_tax config variable (can be added to EE's index.php in the $assign_to_config) to make it so that discounts do not affect taxes.

Is it possible to get a bit of an explanation on how this works. Based in the UK I would charge tax to customers in Europe but not outside Europe. If a discount is valid in either case I need the tax to be calculated correctly in both circumstances.

1 Answer 1

1

You can sort of think of it as applying the discount before or after tax. Say for example, we have a cart with a subtotal of $20, a discount of $10, and a tax of 10%.

The default method works similar to this:

(Subtotal($20) - Discount($10)) + ((Subtotal($20) - Discount($10)) * Tax(.10)) = Total($11)

(20-10) + ((20-10) * .10) = 11

With the exempt_discount_from_tax config added, it works similar to this:

Subtotal($20) + (Subtotal($20) * Tax(.10)) - Discount($10) = Total($12)

20 + (20 * .10) - 10 = 12

Now with that said, that config variable was only intended to be set once. It wasn't meant to be changed on the fly. If you need to be able to configure that variable based on country code, you'll need to modify a core cartthrob file.

In third_party/cartthrob/cartthrob/core/Cartthrob_cart.php

Line 1132. Change

if ($this->core->config('exempt_discount_from_tax') == TRUE)

to

if ($this->core->config('exempt_discount_from_tax') == "y")

Then inside your template you'll be able to set that config using the {exp:cartthrob:set_config} tag pair.

{exp:cartthrob:customer_info}
    {exp:cartthrob:set_config}
        {set_exempt_discount_from_tax value='{if "{customer_country_code}" == "USA"}y{if:else}n{/if}'}
    {/exp:cartthrob:set_config}
{/exp:cartthrob:customer_info}
1
  • Hi Chris, thanks for that. But the discount value is always calculated on the subtotal excluding vat right? So if I have a 50% discount the discount value added to the order would not actually be the correct discount. For example subtotal = £20 inc vat (20%) and I want to apply a 50% discount which would be £10. My total should show £10 inc VAT (£1.67 vat) with a discount of £10.
    – Kenny
    May 20, 2014 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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