Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2008
    Posts
    33
    Plugin Contributions
    0

    Default Total Not Calculating Coupon

    Total Not Calculating Coupon. I had an order come in and the discount was applied properly, but not added in the order total. The coupon is $10 off orders of $50 or more. Below are the order totals, any help is greatly appreciated.


    Sub-Total: $51.75
    Delivery: $2.99
    Discount: -$10.00
    State Tax: $3.04
    Local Tax: $0.82
    Total: $58.60

  2. #2
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Total Not Calculating Coupon

    Are you using the Local Sales Tax module? If so, this is where your problem lies. The Local Sales Tax module ignores any coupons or discounts, and just adds the Tax and Shipping to the Order SubTotal, and makes this the Order Total.

    The update you need is:

    Find this line of code within includes/modules/order_total/ot_local_sales_tax.php
    Code:
                        $taxRateLocal = $taxResult->fields['local_tax_rate'];
    And add teh follwoing code after:

    Code:
    $order_discount = ($order->info['shipping_cost'] + $order->info['subtotal']) - $order->info['total'];
    if ($order_discount > 0) {
      $debug2 .= 'Order total '.$order->info['total'].'<br />';
      $percentage_discount = ($order->info['total'] / ($order->info['total'] + $order_discount));
      $debug2 .= '<b>Percentage Discount</b>'.$percentage_discount.'<br />';
    } else {
      $percentage_discount = 1;
    }
    $taxable_amount = $percentage_discount * ($Taxable_Subtotal + ($order->info['shipping_cost'] * (int)$ot_local_sales_taxes_charge_tax_on_shipping));
    A few lines further down you'll find
    Code:
    //use zen cart tax function to calculate the tax (Taxable subtotal + shipping if needed)
    $LocalTaxTotal = zen_calculate_tax(.........
    Replace this with

    Code:
    //use zen cart tax function to calculate the tax (Taxable subtotal + shipping if needed)
    $LocalTaxTotal = zen_calculate_tax($taxable_amount, $taxRateLocal);

    Finally, below this, find

    Code:
    $order->info['total'] = $order->info['shipping_cost'] + $order->info['subtotal'] + $order->info['tax'];
    And replace it with

    Code:
    $order->info['total'] += $order->info['tax'];
    As with all updates, BACKUP first!

    Absolute
    Back, after a 4 year absence! Did you miss me?
    Absolute Web Solutions Ltd
    Interested in our work? Take a look at one of our sites - The Tech Store

  3. #3
    Join Date
    Nov 2008
    Posts
    33
    Plugin Contributions
    0

    Default Re: Total Not Calculating Coupon

    Hi Absolute, thank for your response. I made the changes, but the error still occurs any other insight would be greatly appreciated.

  4. #4
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Total Not Calculating Coupon

    I've offered up the code we use to fix this problem, so my only other advice is to use the debug2 variable to see where the problem is occuring.

    Absolute
    Back, after a 4 year absence! Did you miss me?
    Absolute Web Solutions Ltd
    Interested in our work? Take a look at one of our sites - The Tech Store

  5. #5
    Join Date
    Nov 2008
    Posts
    33
    Plugin Contributions
    0

    Default Re: Total Not Calculating Coupon

    Absolute, thanks for your help after making changes to the order totals sort order I was able to get the discounts to calculate correctly.

  6. #6
    Join Date
    Sep 2009
    Posts
    71
    Plugin Contributions
    0

    Default Re: Total Not Calculating Coupon

    I have a problem relating to this I have implemented Newsletter discount and Discount Coupon. Newsletter 5% discount - Coupon 20% . The Total percentage taken off the subtotal is correct however if i use the numeric value beeing displayed it doesnt make sense.


    £18.38
    Sub-Total:

    £0.00
    Free Shipping Options (Free Shipping):

    -£3.68
    Discount Coupon: BikeForceFriends&Fam :

    -£0.78
    Newsletter Discount:

    £2.05
    UK VAT:

    £13.78


    so the overall percentage ammount is correct - 18.38 * 0.75 = 13.77 ish

    however 18.38 -0.78 -3.68 = 13.92

    So to the customer that wouldn make sense.

    I would also like to show subtotal with out the tax as it seems to the untrained eye like the tax will be added on although it already has been. But I still want to show tax on the product pages...

    Does anyone know anything about this?
    Last edited by Bikeforce; 21 Jan 2010 at 03:57 PM.

  7. #7
    Join Date
    Sep 2009
    Posts
    71
    Plugin Contributions
    0

    Default Re: Total Not Calculating Coupon

    Quote Originally Posted by Bikeforce View Post

    so the overall percentage ammount is correct - 18.38 * 0.75 = 13.77 ish
    so the overall percentage ammount is correct - 18.38 * 0.75 = 13.785

  8. #8
    Join Date
    Sep 2008
    Posts
    11
    Plugin Contributions
    0

    Default Re: Total Not Calculating Coupon

    Thanks a ton for the fix Absolute.

    I just have one side note. Most people that use the local sales tax might be separating their tax into state and county. Therefore you may already have a tax amount on your order total from the state when you go to calculate the discount before applying the local tax. Therefore you may be taxing the tax. I.E.

    Total $10
    Shipping $10
    Discount $10

    Pretax total
    GA tax 4% = $.40
    Fulton County 3% = (should) $.30

    but Fulton Country is actually taxing $10.40 since the GA tax was already added.

    To fix this, your line reading:

    $order_discount = ($order->info['shipping_cost'] + order->info['subtotal']) - $order->info['total'];

    Should read:

    $order_discount = ($order->info['shipping_cost'] + order->info['subtotal']) - ($order->info['total'] - $order->info['tax']);


    I cannot guarantee this for anyone, but it worked for me.

  9. #9
    Join Date
    Sep 2008
    Posts
    11
    Plugin Contributions
    0

    Default Re: Total Not Calculating Coupon

    My logic is wrong on my last post. There is more that is needed. I am researching and will post my findings.

  10. #10
    Join Date
    Sep 2008
    Posts
    11
    Plugin Contributions
    0

    Default Re: Total Not Calculating Coupon

    Absolute,

    For my logic fix I removed any non local tax from the order total before your discount calculations and left it out because your code adds it back later.

    if ($order->info['tax'] > 0)
    {
    $order->info['total'] = $order->info['total'] - $order->info['tax'];
    }

    This seems to work well for me.

 

 

Similar Threads

  1. Sub Total not calculating correctly with quantity discounts
    By tbaquatics in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 16 Nov 2009, 10:38 PM
  2. Coupon Not Calculating in Price
    By reneeLP in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 19 Nov 2008, 09:46 PM
  3. Order Total Not Calculating Coupon
    By wardrobe911 in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 5
    Last Post: 31 Oct 2008, 10:13 PM
  4. Coupon not subtracting from total
    By captonzoom in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 9
    Last Post: 18 Jul 2008, 04:39 PM
  5. VAT not calculating correct after using Discount Coupon
    By infocom in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 16
    Last Post: 26 Mar 2007, 09:51 AM

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