Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Error in Discount Code Math


Recommended Posts

Posted

First the stats: OsC Phoenix 1.0.2.4,  Discouont Code addon 5.1.1

As you can (maybe see) in the image below, the subtotal is correct, the Discount is correct, but the total excludes the discount.  Which file is doing this math and saving the total?

ord_tot.gif

Steve in Ellenton, FL

Posted

Hello Steve @bnguru,

Please post addons support questions in the appropriate support topic:

Discount Code BS

the file where the calc is done is:
includes/modules/order_total/ot_discount.php

  • Which tax setting are you using in your store?
  • Which payment module did you use in this example?
  • Do you have any aditional modification/addons added to the checkout pages/process/involved files?

I'll then check on my test store.

Best regards
Rainer

Posted
6 hours ago, raiwa said:

 

  • Which tax setting are you using in your store? - in this test, no tax
  • Which payment module did you use in this example? - check/money order
  • Do you have any aditional modification/addons added to the checkout pages/process/involved files? - no

Steve in Ellenton, FL

Posted
20 hours ago, bnguru said:
  • Which tax setting are you using in your store? - in this test, no tax

I meant by tax setting: My Store => show prices with tax true or false

Anyway I could recreate the error which was introduced with 5.1.1. fix for another wrong order total calc if tax is used (if I well remember).

Please apply the following fix:

in: includes/modules/order_total/ot_discount.php
find around line 208-210:

                  if (!empty($order_tax)) {
                    $order->info['tax'] = $order_tax;
                  }

and replace with:

                  if ( tep_not_null($order->info['tax']) ) {
                    $order->info['tax'] = $order_tax;
                  } else {
                    $order->info['total'] -= $discount;                  
                  }

Please let me know and I'll upload the update with this fix.

Posted

Rainer, this seems to have fixed it. Both the previous order worked and I tried it using PayPal standard and it worked as well.  I have not tried it charging tax yet.

Steve in Ellenton, FL

Posted

Hello Steve,

The good one to address also the previous issue, if discount is higher than order subtotal, is:

line 164:

                    $order_tax = $order->info['tax'];

and lines 209-213:

                  if ( tep_not_null($order_tax)) {
                    $order->info['tax'] = $order_tax;
                  } else {
                    $order->info['total'] -= $discount;                  
                  }

 

Posted

Update uploaded with the above fix:

Discount Code 5.1.2. Phoenix

Please apply these fixes also to previous versions.

Older versions, FROZEN, EDGE and Gold BS3, please use Discount_Codes_4.4.3_BS

Version 5.1.2.:
   Fix for wrong order total showing when no tax is applied. Thanks to @bnguru for the report and testing
   Added support for stripe sca 3.0 payment module. Thanks to @peterespana for testing
   Fixed several minor errors in instructions, ot module and admin page. Thanks to @Demitry

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...