Page 1 of 6 123 ... LastLast
Results 1 to 10 of 54
  1. #1
    Join Date
    Jun 2005
    Location
    Kelowna, BC Canada
    Posts
    1,075
    Plugin Contributions
    6

    Default tax calculation problem with coupons and multiple products

    This requires more testing because I'm not entirely sure what is triggering this bug, but it is repeatable and here is the scenario:

    Canadian store with GST zone (all of Canada) and PST zone (just BC) and HST zone (Atlantic provinces).

    Store is v 1.3.6. Mods are many, so I ask that someone with an fresh site try it to confirm (I will when I get back from vacation)

    Issued a coupon code with a product restriction so it applied to only one item.

    Customer (from Quebec, so only GST applies) ordered that item as well as another item, and used the coupon code.

    Shipping applied correctly.

    Taxes calculated very odd (too low) and I can't figure out why.

    BEFORE entering the coupon code, I get this:

    Item 1: $221.00
    Item 2: $35.00
    Shipping: $26.91
    Tax (6%): $16.97
    Total: $299.88

    And that is correct! But after entering the coupon code, I get:

    Item 1: $221.00
    Item 2: $35.00
    Shipping: $26.91
    Coupon: -$132.60
    Tax (6%): $7.75 <-- Incorrect! Should be $9.02
    Total: $158.06 <-- should be $159.33

    The tax (and therefor the total) are completely wrong!

    It only seems to happen when a coupon is applied, which is restricted to one product, and another product is ordered at the same time. However, I have not thoroughly tested other scenarios to see if it is also a problem with a different set of circumstances.

    I have other orders with coupon codes restricted to a certain product... but in each of those cases the customer only ordered that item and nothing else. This is the first time I've had this situation, but I can repeat it.

    - Steven

  2. #2
    Join Date
    Sep 2004
    Posts
    745
    Plugin Contributions
    4

    Default Re: tax calculation problem with coupons and multiple products

    Steven,

    I too am looking closely at the coupon code as it is very different from what I am currently using and I am also getting strange results. Do you mind testing what I am using for ot_coupon.php here and advising if you get correct totals when using this version?

    Thanks,
    Jeff

  3. #3
    Join Date
    Jun 2005
    Location
    Kelowna, BC Canada
    Posts
    1,075
    Plugin Contributions
    6

    Default Re: tax calculation problem with coupons and multiple products

    Interesting! Yes, it seems to have solved it... almost.

    Now I get this:

    Item 1: $221.00
    Item 2: $35.00
    Shipping: $26.91
    Coupon: -$132.60
    Tax (6&#37;): $9.01 <-- Incorrect! Should be $9.02
    Total: $159.32 <-- should be $159.33

    Very close, but it is rounding incorrectly. You can confirm this yourself... (221+35+26.91-132.6) * .06 = 9.0186 which should round up not down.


    warning
    Your code seems to have introduced another bug... if the customer doesn't finish checking out and manages to find themselves back on the payment page, they have the option to enter REMOVE into the coupon box to remove it. The original code this worked, but with yours it does remove the coupon but presents the user with a blank page.

    Of course, I really doubt many people ever use this during a normal transaction. The only reason I know the original file works and yours doesn't is because I'm monkeying around going back and forth... still, it should get fixed.


    Hope that helps! Thanks for your efforts on this.

    - Steven

  4. #4
    Join Date
    Jun 2005
    Location
    Kelowna, BC Canada
    Posts
    1,075
    Plugin Contributions
    6

    Default Re: tax calculation problem with coupons and multiple products

    Hmm... possibly the rounding thing is correct now that I look at it again. I'm not sure how zen does its calculations... but if it seperately calculates tax on shipping vs. everything else (which it should) then the result is 7.4040 + 1.6146 = 9.0146 which would round down. If it does seperate them, it does it in the background because the taxes are all together when presented to the customer. At least it is on mine.

    - Steven

  5. #5
    Join Date
    Sep 2004
    Posts
    745
    Plugin Contributions
    4

    Default Re: tax calculation problem with coupons and multiple products

    Steven,

    Yes it does them separately so again yes I do feel the totals are correct in your above scenario. I will have to look into the REMOVE feature and figure out when that was added and fix it. I have been using "my" version of ot_copon.php for a long time without updating as I have had problems getting correct totals with previous versions 1.3.02-1.3.7 in certain coupon cases so I probably have never updated the file contents to support a REMOVE feature. I will look into it and let you know.

    Thanks for the feedback,
    Jeff

  6. #6
    Join Date
    Sep 2004
    Posts
    745
    Plugin Contributions
    4

    Default Re: tax calculation problem with coupons and multiple products

    Steven,

    Comparing the two files I can see no difference that would make the REMOVE functionality fail IMHO. Can you please verify this for certain, that it is not something else causing the problem?

    Thanks,
    Jeff

  7. #7
    Join Date
    Nov 2003
    Location
    Haarlem | Netherlands
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: tax calculation problem with coupons and multiple products

    I can confirm the REMOVE functionality fails Jeff.

    It works if I use my ot_coupon version (= a slightly modified 1.3.6 version), but when I use yours I get:
    Warning: Cannot modify header information - headers already sent by (output started at /home/domains/beterelektro.nl/public_html/includes/modules/order_total/ot_coupon.php:1) in /home/domains/beterelektro.nl/public_html/includes/functions/functions_general.php on line 44
    The tax seems to be calculated correctly though. I only tried absolute discounts on a shop showing prices including tax.

    But when I apply a freeshipping coupon it substracts (the coupon also shows a value with tax applied twice to it on checkout) the shipping tax twice form the order total.

  8. #8
    Join Date
    Nov 2003
    Location
    Haarlem | Netherlands
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: tax calculation problem with coupons and multiple products

    Posted to early.

    The headers already sent is caused by a couple of spaces at the top of the file:
    Code:
         <?php
    /**
     * @package orderTotal
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: ot_coupon.php 4562 2006-09-19 19:11:08Z wilt $
     */
    When I remove those the REMOVE coupon works fine again :-)

    Any ideas about the doubled freeshipping tax? (of course I could add a line to prevent the tax being applied twice, but i would rather know the cause of it, if possible).

  9. #9
    Join Date
    Sep 2004
    Posts
    745
    Plugin Contributions
    4

    Default Re: tax calculation problem with coupons and multiple products

    I believe the double tax on shipping is due to my commenting out line 45 in the file.

    Code:
    // if ($od_amount['type'] == 'S') $order->info['shipping_cost'] = 0;
    If you remove the comments from in front of this line I believe the calculation for the free shipping coupon will be correct. Please try this and let me know?

    Thanks for pointing out the spaces Paul!

    Jeff

    PS: I have updated the posted file with this change.

  10. #10
    Join Date
    Nov 2003
    Location
    Haarlem | Netherlands
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: tax calculation problem with coupons and multiple products

    Hi Jeff,

    I already tried uncommenting that line, but to my suprise it seemed to make no difference at all (I will give it another shot though, maybe I made an error?).

    I added an (ugly!) hack which fixes the freeshipping coupon amount, but the tax is slightly wrong then (while it's correct with other coupon types now, thanks for that! :-) ).

    The hack is that I added the second line in the code below:
    Code:
                        $od_amount['tax'] -= ($order->info['shipping_cost'] * $tax_rate)/100;
                        $od_amount['total'] += $od_amount['tax']; // !hack :: trying to fix double taxing with freeshipper coupons
                        $od_amount[$tax_desc]  += ($order->info['shipping_cost'] * $tax_rate)/100;
    Which is within the "// JTD:04/20/06 - added support to subtract coupon tax from tax total when shipping includes tax" part.

 

 
Page 1 of 6 123 ... LastLast

Similar Threads

  1. Problem with Tax calculation
    By ianhg in forum General Questions
    Replies: 7
    Last Post: 27 Apr 2009, 09:09 PM
  2. Problem with tax calculation on Tax Exempt goods
    By vickula in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 3
    Last Post: 25 Mar 2009, 03:49 PM
  3. tax calculation error with coupons
    By poosk in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 1
    Last Post: 22 Oct 2008, 02:35 PM
  4. Replies: 0
    Last Post: 13 Jun 2008, 12:57 PM
  5. Coupons and Tax calculation in Europe
    By cdelab in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 0
    Last Post: 13 Jan 2008, 07:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR