Forums / Bug Reports / Discount Coupon Tax issue

Discount Coupon Tax issue

Views: 2,304

Results 1 to 9 of 9
30 May 2025, 11:36 AM
#1
ryk avatar

ryk

Totally Zenned

Join Date:
Oct 2004
Location:
Southport, UK
Posts:
3,644
Plugin Contributions:
6

Discount Coupon Tax issue

We came across the following issues when applying Discount Coupons:

  • Fixed amount discount coupons apply more discount than configured eg. £0.20 coupon applied £0.23 discount instead
  • Percentage discount coupons calculate against tax-inclusive prices regardless of tax settings eg. 10% discount on £1.00 + VAT (displayed as £1.20) showed as £0.12 instead of £0.10
    **
    Cause**

When DISPLAY_PRICE_WITH_TAX is set to true, the coupon module incorrectly handles tax in two ways:

  • Base calculation issue: Percentage discounts are calculated against tax-inclusive amounts even when MODULE_ORDER_TOTAL_COUPON_INC_TAX is set to false
  • Final amount issue: Tax is incorrectly added to fixed amount coupons even when MODULE_ORDER_TOTAL_COUPON_INC_TAX is set to false
    **
    Solution**

Two changes are required in includes/modules/order_total/ot_coupon.php**

Fix 1: Base Calculation (Line 683)**
From:

if (DISPLAY_PRICE_WITH_TAX !== 'true') {


To**:**

if (DISPLAY_PRICE_WITH_TAX !== 'true' || $this->include_tax !== 'true') {


Why needed

This ensures that tax is removed from the base order total when calculating discounts if the coupon module is configured to exclude tax, regardless of how prices are displayed in the store.**

Fix 2: Final Amount (Line 597)**
From:

if (DISPLAY_PRICE_WITH_TAX == 'true' && $coupon_details['coupon_type'] == 'F') {


To**:**

if (DISPLAY_PRICE_WITH_TAX == 'true' && $coupon_details['coupon_type'] == 'F' && $this->include_tax == 'true') {


Why needed

This prevents tax from being added to the final discount amount for fixed amount coupons when the coupon module is configured to exclude tax. Both fixes ensure the coupon module properly respects the MODULE_ORDER_TOTAL_COUPON_INC_TAX setting throughout all calculations.

Note:
This issue was initially noticed in Zen Cart 2.1.0 but may exist in other versions

Development Manager @ JSWeb Ltd - suppliers of Applepay/Googlepay for Zencart
20 years with Zencart !

31 May 2025, 1:01 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Discount Coupon Tax issue

Thanks for the report and details! I've created a GitHub PR containing those changes: https://github.com/zencart/zencart/pull/7121

2 Jun 2025, 1:32 PM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Discount Coupon Tax issue

@Ryk, please see comments made in the GitHub pull request; there are apparently some issues with the suggested changes.

2 Jun 2025, 6:42 PM
#4
pilou2 avatar

pilou2

Zen Follower

Join Date:
Jun 2008
Location:
Japan
Posts:
414
Plugin Contributions:
6

Re: Discount Coupon Tax issue

... you are moving into a land of both shadow and substance of things and ideas, you have just crossed over into the TWILIGHT ZONE!!!

A little bit of humor that I think describes the situation well enough... unfortunately.
A pity I can't add the music.

ZC v2.2.2 PHP 8.4+ MySQL 8.4+

21 Jun 2025, 10:55 AM
#5
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Discount Coupon Tax issue

@Ryk would you please sign off on https://github.com/zencart/zencart/pull/7121 or state objections so it can be dealt with? Thanks.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

21 Jun 2025, 12:00 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Discount Coupon Tax issue

swguy:

@Ryk would you please sign off on https://github.com/zencart/zencart/pull/7121 or state objections so it can be dealt with? Thanks.
Right, otherwise I'm just going to withdraw the PR that I'd submitted on your behalf.

22 Jun 2025, 1:18 PM
#7
ryk avatar

ryk

Totally Zenned

Join Date:
Oct 2004
Location:
Southport, UK
Posts:
3,644
Plugin Contributions:
6

Re: Discount Coupon Tax issue

Sorry - I'm not understanding what you want from me.

All I know is that we found a problem that appeared to be a ZenCart bug and created a solution which works for us.

I'll ask our developers to look at github to se4e if further comment is needed.

Development Manager @ JSWeb Ltd - suppliers of Applepay/Googlepay for Zencart
20 years with Zencart !

22 Jun 2025, 2:32 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Discount Coupon Tax issue

Ryk:

Sorry - I'm not understanding what you want from me.

All I know is that we found a problem that appeared to be a ZenCart bug and created a solution which works for us.

I'll ask our developers to look at github to se4e if further comment is needed.
The solution you provided doesn't work for all store configurations; those are pointed out by @piloujp's comments in the PR I submitted on your behalf.

For the change to be accepted into the Zen Cart base, the change needs to result in correct calculations for all scenarios.

23 Jun 2025, 10:10 AM
#9
ryk avatar

ryk

Totally Zenned

Join Date:
Oct 2004
Location:
Southport, UK
Posts:
3,644
Plugin Contributions:
6

Re: Discount Coupon Tax issue

OK. Well, we had a problem with the core code and found a solution that resolved it for our situation. It would no doubt work for people with the same settings, but we currently do not have the resources to investigate further using condtional settings not applicable to ourselves, especially in the light of piloujp's last comment which seems to indicate that there is a long-standing issue on which a considerable amount of time has already been spent without achieving a full resolution.

Thank you for looking into this and please do as you wish with our report.

Development Manager @ JSWeb Ltd - suppliers of Applepay/Googlepay for Zencart
20 years with Zencart !