Zen Cart Logo
Forums / Bug Reports / Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

Views: 29,250

Results 1 to 20 of 59
28 Aug 2013, 8:06 AM
#1
gam avatar

gam

Zen Follower

Join Date:
Aug 2007
Posts:
116
Plugin Contributions:
0

Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

I have a webshop in Australia, where we use GST-included in our prices. 10%

I'm getting a rounding error on checkout subtotal. Shopping Cart product totals and Subtotal are calculated correctly but Checkout and subsequent order Subtotals are not.

Example:

Price 1.181 * Tax 0.10 = 1.2991
Rounded = 1.30

  • 10 units

Subtotal = 13.00

Shopping Cart is calculating as above, which is correct.

On checkout (and subsequent confirmed order), sub total is calculated to 12.99, which only makes sense if rounding and/or tax was calculated on subtotal at the checkout/order total stage.

New, very modded Zen 1.5 site.
Possible suspects; Store Credits and Rewards Points Module, Super Orders 4.0, Edit Order 4.1.2 or some remnant of uninstalled Fast Easy Checkout. More likely; Stupid GAM user error somewhere

I've searched the forums and threads on this matter and above add-ons and could not find anything related. Some similar issues but different and normally explained/resolved. I've spent hours now poking through my php files but I just don't understand it well enough to look in the right places I think. I see the code for the Shopping Cart, which I can interpret and identify is calculating correctly. But no idea where the actual calculations are occurring for the Order Total section of the Checkout, and what is saved for the order.

If someone could at least point me in the right direction I'm likely to find the culprit and fix.

Cheers
GAM - the frazzled :frusty:

ps. Went live 4:30am Tuesday and mostly sleepless since :wacko:... gammods[dot]com[dot]au store

21 Mar 2014, 6:28 AM
#2
letslearnit avatar

letslearnit

New Zenner

Join Date:
Jul 2012
Posts:
4
Plugin Contributions:
0

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

I'm having this problems too but I don't known this problem comes from Zencart core or comes from Ad-on.

21 Mar 2014, 2:14 PM
#3
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

Are you using FEC? And does it happen when you switch to the Classic Green Template?

21 Mar 2014, 5:44 PM
#4
lat9 avatar

lat9

Administrator

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

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

If I apply the calculations in the order that Zen Cart's "standard" processing would do:

10 x 1.181 = 11.81 x 1.1 (10% tax) = 12.991 ... rounded is 12.99

So I created a test product in a "stock" Zen Cart v1.5.1 store (using all default settings) that has a price of 1.181. Added 10 of them to my cart. Price displays as 11.80 (incorrect, should be 11.81). I then went to checkout and see the correct subtotal (11.81) with a 1.18 tax (10%) yielding a final price of 12.99.

That said, I believe that the rounding error is on the shopping_cart page, but I'm not sure (yet) what the culprit is.

21 Mar 2014, 6:07 PM
#5
lat9 avatar

lat9

Administrator

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

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

If you agree with my assertion that the rounding should occur ***after ***the per-product-price is multiplied by the cart quantity, then the following changes will move the processing on the shopping_cart page into line with the ot_subtotal calculation. All line numbers are relative to an unmodified v1.5.1 version of the specified file.

First, /includes/classes/shopping_cart.php, starting at line #850:

//      $this->total += zen_round(zen_add_tax($productTotal, $products_tax), $decimalPlaces) * $qty;
      $this->total += zen_round(zen_add_tax($productTotal, $products_tax) * $qty, $decimalPlaces);  //-lat9-correct rounding issue

Then, /includes/pages/shopping_cart/header_php.php starting at line #141

//-bof-lat9-fix rounding issue
//  $ppe = zen_round(zen_add_tax($ppe, zen_get_tax_rate($products[$i]['tax_class_id'])), $currencies->get_decimal_places($_SESSION['currency']));
//  $ppt = $ppe * $products[$i]['quantity'];
  $ppe = zen_add_tax($ppe, zen_get_tax_rate($products[$i]['tax_class_id']));
  $ppt = zen_round ($ppe * $products[$i]['quantity'], $currencies->get_decimal_places($_SESSION['currency']));
//-eof-lat9
25 Jul 2014, 12:05 PM
#6
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

Similar scenario here on a 1.5.1 shop. Only noted now that the sub-totals are not displaying correctly during checkout if the cart contains multiples of discounted products. The sub-totals were showing correctly in my previous 1.3.9h version of this site.

item cost $32.35 each, 2 items in cart > shopping cart shows $64.70 (correct)
getting to checkout payment page and sub-total shows $64.71 (1 cent more ??)

item cost $31.64 each, 4 items in cart > shopping cart shows $126.56 (correct)
getting to checkout payment page and sub-total shows $126.54 (2 cents less ??)

item cost $30.56 each, 6 items in cart > shopping cart shows $183.36 (correct)
getting to checkout payment page and sub-total shows $183.34 (2 cents less ??)

It would not matter if I selected a product with quantity discounts or any other product without quantity discounts. But it seems to affect all products with a specials price - say 10% or 15% or whatever percentage off.

lat9:

If you agree with my assertion that the rounding should occur ***after ***the per-product-price is multiplied by the cart quantity, then the following changes will move the processing on the shopping_cart page into line with the ot_subtotal calculation. All line numbers are relative to an unmodified v1.5.1 version of the specified file.

First, /includes/classes/shopping_cart.php, starting at line #850:

// $this->total += zen_round(zen_add_tax($productTotal, $products_tax), $decimalPlaces) * $qty;
$this->total += zen_round(zen_add_tax($productTotal, $products_tax) * $qty, $decimalPlaces); //-lat9-correct rounding issue

> 
> Then, /includes/pages/shopping_cart/header_php.php starting at line #141
> ```
//-bof-lat9-fix rounding issue
//  $ppe = zen_round(zen_add_tax($ppe, zen_get_tax_rate($products[$i]['tax_class_id'])), $currencies->get_decimal_places($_SESSION['currency']));
//  $ppt = $ppe * $products[$i]['quantity'];
  $ppe = zen_add_tax($ppe, zen_get_tax_rate($products[$i]['tax_class_id']));
  $ppt = zen_round ($ppe * $products[$i]['quantity'], $currencies->get_decimal_places($_SESSION['currency']));
//-eof-lat9

Tried your suggestion on a local clone of this site and compared results to the unchanged live site with same products and prices in the cart - to no avail - same result.

Any other ideas please??

Thanks / Frank

25 Jul 2014, 1:11 PM
#7
lat9 avatar

lat9

Administrator

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

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

Frank, it looks like there's a similar change to be made to /includes/classes/order.php, in the cart function:

      /*********************************************
       * Calculate taxes for this product
       *********************************************/
//-bof-20140725-lat9-Correct rounding error
//     $shown_price = (zen_add_tax($this->products[$index]['final_price'] * $this->products[$index]['qty'], $this->products[$index]['tax']))
//      + zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']);
      $shown_price = (zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'])
      + zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']);
//-eof-20140725-lat9
      $this->info['subtotal'] += $shown_price;

I haven't tested this out, but I believe that it will correct the calculations.

25 Jul 2014, 2:20 PM
#8
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

lat9:

Frank, it looks like there's a similar change to be made to /includes/classes/order.php, in the cart function:

  /*********************************************
   * Calculate taxes for this product
   *********************************************/

//-bof-20140725-lat9-Correct rounding error
// $shown_price = (zen_add_tax($this->products[$index]['final_price'] * $this->products[$index]['qty'], $this->products[$index]['tax']))
// + zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']);
$shown_price = (zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'])
+ zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']);
//-eof-20140725-lat9
$this->info['subtotal'] += $shown_price;

> I haven't tested this out, but I believe that it will correct the calculations.

Thanks lat9, sadly it's a no go. Bedtime for me, I have a look into includes/classes/currencies.php tomorrow.
26 Jul 2014, 7:17 AM
#9
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

Local install - temporarily replaced the following 1.5.1 files with corresponding 1.5.3 files:

/includes/classes/shopping_cart.php
/includes/classes/order.php
/includes/classes/order_total.php

and sadly getting the same result -->> 1 or 2 cents differnece between cart and checkout pages, so no go again!

26 Jul 2014, 9:14 AM
#10
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

lat9:

If I apply the calculations in the order that Zen Cart's "standard" processing would do:

10 x 1.181 = 11.81 x 1.1 (10% tax) = 12.991 ... rounded is 12.99

So I created a test product in a "stock" Zen Cart v1.5.1 store (using all default settings) that has a price of 1.181. Added 10 of them to my cart. Price displays as 11.80 (incorrect, should be 11.81). I then went to checkout and see the correct subtotal (11.81) with a 1.18 tax (10%) yielding a final price of 12.99.

That said, I believe that the rounding error is on the shopping_cart page, but I'm not sure (yet) what the culprit is.

Created a test product with a price of $5.95 (inc tax)

Tax rate = 10%

Net before tax = $5.4091. This is the value found stored in the DB table 'products'

Added 7 items to the cart. Cart sub total is $41.65 (correct - as it should be)

Checkout payment page shows $41.65 (correct)

Next I created a special for this product: 10% off

Product info page shows: $5.95 normal price with a specials price of $5.36 - this is what the customer is seeing (important to note!!)

Mathematically this is: $5.95 - 10% = $5.355

Now the cart shows $37.52 which is correct from a customer point of view

Mathematically this is $5.355 * 7 = $37.485

Checkout payment page now shows $37.49 . Looks like this is derived from mathematically correct rounding of the previous line which shows $37.485

It should show the same value as the cart, namely $37.52

The DB now shows a specials price of $4.8682 for this test product. Add 10% tax and the gross price per unit should be 5.35502 (see the $5.355 above as mathematically calculated)

So I am thinking that along the trails of scripts and files ZC keeps reverting back to values found in the DB and continues from there instead of just calculating on from the specials price visible to the customer.

IMHO this appears to be a genuine bug in the logic of ZC ???

What do you think? Are you able to replicate this on a fresh install - be it 1.5.1 or 1.5.3?

Cheers / Frank

29 Jul 2014, 2:34 PM
#11
lat9 avatar

lat9

Administrator

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

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

Try the following change to the currencies-class display_price function (both /includes/classes/currencies.php and /YOUR_ADMIN/includes/classes/currencies.php):

  function display_price($products_price, $products_tax, $quantity = 1) {
//-bof-20140729-lat9-Fix rounding error with tax calculation
//      return $this->format(zen_add_tax($products_price, $products_tax) * $quantity);
    return $this->format (zen_add_tax($products_price * $quantity, $products_tax));
//-eof-20140729-lat9-Fix rounding error ...
  }
29 Jul 2014, 2:51 PM
#12
lat9 avatar

lat9

Administrator

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

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

lat9:

If I apply the calculations in the order that Zen Cart's "standard" processing would do:

10 x 1.181 = 11.81 x 1.1 (10% tax) = 12.991 ... rounded is 12.99

So I created a test product in a "stock" Zen Cart v1.5.1 store (using all default settings) that has a price of 1.181. Added 10 of them to my cart. Price displays as 11.80 (incorrect, should be 11.81). I then went to checkout and see the correct subtotal (11.81) with a 1.18 tax (10%) yielding a final price of 12.99.

That said, I believe that the rounding error is on the shopping_cart page, but I'm not sure (yet) what the culprit is.

lat9:

If you agree with my assertion that the rounding should occur ***after ***the per-product-price is multiplied by the cart quantity, then the following changes will move the processing on the shopping_cart page into line with the ot_subtotal calculation. All line numbers are relative to an unmodified v1.5.1 version of the specified file.

First, /includes/classes/shopping_cart.php, starting at line #850:

// $this->total += zen_round(zen_add_tax($productTotal, $products_tax), $decimalPlaces) * $qty;
$this->total += zen_round(zen_add_tax($productTotal, $products_tax) * $qty, $decimalPlaces); //-lat9-correct rounding issue

> 
> Then, /includes/pages/shopping_cart/header_php.php starting at line #141
> ```
//-bof-lat9-fix rounding issue
//  $ppe = zen_round(zen_add_tax($ppe, zen_get_tax_rate($products[$i]['tax_class_id'])), $currencies->get_decimal_places($_SESSION['currency']));
//  $ppt = $ppe * $products[$i]['quantity'];
  $ppe = zen_add_tax($ppe, zen_get_tax_rate($products[$i]['tax_class_id']));
  $ppt = zen_round ($ppe * $products[$i]['quantity'], $currencies->get_decimal_places($_SESSION['currency']));
//-eof-lat9

I gave this a look again, based on the additional findings (posted above) in the currencies classes' calculations and now modify my suggestions for the above changes to read:

//      $this->total += zen_round(zen_add_tax($productTotal, $products_tax), $decimalPlaces) * $qty;
     $this->total += zen_round (zen_add_tax ($productTotal * $qty, $products_tax), $decimalPlaces);  //-lat9-correct rounding issue

and

//-bof-lat9-fix rounding issue
//  $ppe = zen_round(zen_add_tax($ppe, zen_get_tax_rate($products[$i]['tax_class_id'])), $currencies->get_decimal_places($_SESSION['currency']));
//  $ppt = $ppe * $products[$i]['quantity'];
  $ppe = zen_add_tax ($ppe * $products[$i]['quantity'], zen_get_tax_rate($products[$i]['tax_class_id']));
  $ppt = zen_round ($ppe, $currencies->get_decimal_places($_SESSION['currency']));
//-eof-lat9

Each of these changes now enforces the calculation sequence of:

total = zen_round ((unit_price * quantity) * tax)

29 Jul 2014, 9:37 PM
#13
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

Based on your suggestions above I used this test product:

(this is what the customer sees on the product info page and this price should be carried forward through all the calcs)

Test Candle (normal price) $5.95
Test Candle (special price)  $5.36 

Add 10 units to the cart, cart shows

Test Candle 10     $53.55     $53.55
Sub-Total: $53.55    
Order completes and the invoice shows:

Products         SKU         Tax     Price (ex)     Price (inc)     Total (ex)     Total (inc)
10 x     Test Candle     test_candle     10%     $4.87         $5.36         $48.70         $53.60
Sub-Total:     $53.55    (should be $53.60)
Free Shipping Options (Free Shipping):     $0.00
GST:     $4.87
Total:     $53.55    (should be $53.60)

Here we have a 5 cent difference in the total. Mathematically it is correct, but now divide $53.55 / 10 and we get a price of $5.355 each. In the real world there is no such thing as a fraction of a cent. Have not checked the DB entry but I bet that it shows 5.355. So, if a special price is calculated then that needs to be rounded to the nearest cent before it gets stored in the DB.

That would be the next thing to fix.

Cheers / Frank

5 Aug 2014, 11:19 AM
#14
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

Looks like I finally got this issue sorted.

After lots of experimenting, file hunting and tracing - and getting my maths brain into gear I made the changes below.

Files affected:

includes/classes/currencies.php

at the end of the file I changed

  function display_price($products_price, $products_tax, $quantity = 1) { 
    return $this->format(zen_add_tax($products_price, $products_tax) * $quantity); 
  }

to this

  function display_price($products_price, $products_tax, $quantity = 1) { 
    //-bof-frank18-Fix rounding error with tax calculation 
    return $this->format(zen_round(zen_add_tax($products_price, $products_tax), 2) * $quantity); 
    //-eof-frank18-Fix rounding error ... 
  }

includes/classes/order.php

changed (from around line 526)

      /*********************************************
       * Calculate taxes for this product
       *********************************************/
      $shown_price = (zen_add_tax($this->products[$index]['final_price'] * $this->products[$index]['qty'], $this->products[$index]['tax']))
      + zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']);
      $this->info['subtotal'] += $shown_price;
      $this->notify('NOTIFIY_ORDER_CART_SUBTOTAL_CALCULATE', array('shown_price'=>$shown_price));
      // find product's tax rate and description
      $products_tax = $this->products[$index]['tax'];
      $products_tax_description = $this->products[$index]['tax_description'];

to this

      /*********************************************
       * Calculate taxes for this product
       *********************************************/
      //$shown_price = (zen_add_tax($this->products[$index]['final_price'] * $this->products[$index]['qty'], $this->products[$index]['tax'])) // standard ZC1.5.1 code  (frank18)
      // next line is replacement which works a treat  (frank18)
      $shown_price = round((zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax'])), 2) * $this->products[$index]['qty']   
      + zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']);
      $this->info['subtotal'] += $shown_price;
      $this->notify('NOTIFIY_ORDER_CART_SUBTOTAL_CALCULATE', array('shown_price'=>$shown_price));
      // find product's tax rate and description
      $products_tax = $this->products[$index]['tax'];
      $products_tax_description = $this->products[$index]['tax_description']; // - shows correct product totals incl tax (frank18)

**includes/classes/shopping_cart.php
**
changed line 851

      $this->total += zen_round(zen_add_tax($productTotal, $products_tax), $decimalPlaces) * $qty;

to this

      // $this->total += zen_round(zen_add_tax($productTotal, $products_tax), $decimalPlaces) * $qty;
      $this->total += zen_round(zen_add_tax($productTotal, $products_tax), 2) * $qty;  // -frank18- correct rounding issue

Even though $decimalPlaces are set to '2' they won't take (don't know why???) - but by actually specifying 2 decimal places in that line fixed it

Finally in both of these files

includes/functions/functions_prices.php
admin/includes/functions/functions_prices.php

There are 5 instances in each of the 2 files showing

return number_format($blah_blah_variable, 4, '.', '');

which I all changed to

return number_format($blah_blah_variable, 2, '.', '');

I tested this on 3 different local ZC1.5.1 installs with normal priced products, products priced by attributes, products with special prices and products with sale maker prices. All are now showing fine on the shopping cart page, checkout_shipping, checkout_payment, checkout_confirmation and in admin - including the invoice. The fixes are now active on my main live store.

I would be grateful to see some comments on these changes - especially after seeing numerous reports on the same rounding issue on this forum and on the net - dating back to 2008.

If we are lucky, Ajeh (the shipping and payment module specialist :smile:) may take a look at this.

Cheers / Frank

10 Sep 2014, 10:29 PM
#15
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

I may add that this is working fine on a 1.5.3 install.

14 Dec 2014, 12:17 PM
#16
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

BTW, I tested a scenario on a stock ZC 1.5.3 install, testing product paper forms at a cost of 0.00003511 each, minimum buy 100,000. The stock ZC 1.5.3 configuration returns $0.00 in the shopping cart (naturally).

Then again, in a real World nobody sells paper forms at a cost of 0.00003511 each.... that sort of stuff is usually sold in packs of 1,000's or 10,000's - price charged per pack/ream/box, $3.51, $35.11 whatever.

Also, I am yet to find a currency with more than 2 decimals. True, from a manufacturing point of view, the production costs are usually broken down to fractions of cents, but the stuff is never sold to the consumer as an individually produced item but only in minimum quantities.

The code modification which I posted earlier works for me, it may not be suitable for others so use with caution and always backup your files before making changes.

14 Dec 2014, 11:01 PM
#17
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

Sadly this rounding error has been an issue for ages, I even noted similar posts on the OsCommerce forums whilst Googling around so me thinks it's a legacy from that cart.

Sure, my solution of having 2 decimals hardcoded is not ideal at all, but at least it eliminates my accounting system complaining that a transaction is not in balance after importing orders.

Eventually someone will come up with a satisfactory solution.... (Ajeh ????)

Thanks again

Frank

27 Mar 2015, 9:56 AM
#18
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

frank18:

I may add that this is working fine on a 1.5.3 install.

I can confirm that it also works on 1.5.4

17 Jun 2015, 7:48 AM
#19
sarahl avatar

sarahl

Zen Follower

Join Date:
May 2004
Location:
UK
Posts:
471
Plugin Contributions:
0

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

just wanted to post to say thank you - I don't see this error that often anymore but just had it in a live shop - 153 - would be really good if this could be looked at and built into the core code :)

23 Sep 2015, 7:38 PM
#20
margecc avatar

margecc

Zen Follower

Join Date:
Feb 2007
Location:
Ontario, Canada
Posts:
234
Plugin Contributions:
0

Re: Shopping cart Subtotal not equal Checkout Subtotal (rounding error) with GST/VAT

I have a rounding problem here, and oddly enough I am a printing company that sells forms, as mentioned a few threads earlier, and we do sell in partial cents LOL.

I'm going to use my product AF133 as a example at af-company.com. http://af-company.com/index.php?main_page=product_info&products_id=12

I have it displaying both the unit price and the total price, since a unit is quite literally a sheet of paper, so it falls in the fraction cents, I find people get less confused.

Currently my display should show two decimal places, unless the third number saved in the database is something other than "0", in which case it displays the additional 3rd digit ((see prices for 100 at .21 ea, vs 1000 for .174 ea)(although the very first quantity doesn't seem to work and have no idea why)). The calculation shown to the customer is the unit price multiplied by the quantity, as it should be. However when you add this amount to your shopping cart, it is calculating it to only 2 decimal places, so the price for 1000 at 0.174 ea is showing as $170.00. However when you continue on to check out to complete your order, the shopping cart then shows the price correctly at $174.00 for 1000 forms. I have no idea how to fix this discrepancy.

You can use my test account test43770 (at) yourcompany dot com and the p/w is 43770test

Any help is appreciated.