Page 1 of 1

Coupon code to apply to sub-total before tax is applied

Posted: Fri May 17, 2019 11:08 pm
by webs_bd
Version 1.5.6.1

Currently our store shows (for example) a 10% coupon code which is deducted correctly from the goods total; but subsequently after that the VAT is valued from the goods total also, not from the goods total minus the coupon discount, which is what we want. I have changed 'sort order' to many combinations but cannot get the result required. Can anyone help?

Re: Coupon code to apply to sub-total before tax is applied

Posted: Fri May 17, 2019 11:33 pm
by johnp

Re: Coupon code to apply to sub-total before tax is applied

Posted: Sat May 18, 2019 9:42 pm
by Johnathan
Just for reference, Super Coupons can do this, since it bases its calculation on the sub-total without tax by default. However, I think there's an easy edit to get the built-in coupon system to do this, since you just have to skip it applying discounts to tax. Try this edit and see if it works:

Code: Select all

IN:
/catalog/model/total/coupon.php

REPLACE:
if ($product['tax_class_id']) {

WITH:
if (false) {

Re: Coupon code to apply to sub-total before tax is applied

Posted: Mon May 20, 2019 5:58 pm
by webs_bd
Thanks for the reply.
My problem is slightly different. The coupon amount is correct but the VAT is calculated on the total before the coupon, so the total is incorrect - see attachment.

Re: Coupon code to apply to sub-total before tax is applied

Posted: Mon May 20, 2019 7:57 pm
by webs_bd
Johnathan wrote:
Sat May 18, 2019 9:42 pm
Just for reference, Super Coupons can do this, since it bases its calculation on the sub-total without tax by default. However, I think there's an easy edit to get the built-in coupon system to do this, since you just have to skip it applying discounts to tax. Try this edit and see if it works:

Code: Select all

IN:
/catalog/model/total/coupon.php

REPLACE:
if ($product['tax_class_id']) {

WITH:
if (false) {
Thank you for the suggestion. No this did not fix it. In fact investigating this further the coupon does not get deducted at all until it gets taken off the grand total, irrespective of what order the 'order totals' are in.

Re: Coupon code to apply to sub-total before tax is applied

Posted: Mon May 20, 2019 9:38 pm
by Johnathan
Coupons should affect the tax if the products in the cart have Tax Classes on them. The edit I gave you would reverse that, but if the default behavior isn't working, then something's wrong in your installation. The order of the line items does not matter in this case --- the Coupon line item is coded to look at the discount, and deduct it's portion from the taxes.

I'm not sure why it's not working for you. You could use Super Coupons which is its own system, and would work fine with Taxes and how it calculates its discount. If you don't want to get an extension, hopefully someone will post here with some ideas for why it's not working.