Forums / Bug Reports / order total different from cart total

order total different from cart total

Views: 3,434

Results 1 to 10 of 10
19 Nov 2012, 3:55 PM
#1
s_p_ike avatar

s_p_ike

Zen Follower

Join Date:
Feb 2005
Location:
Italy
Posts:
178
Plugin Contributions:
0

order total different from cart total

Situation:

No taxes used

Product Price: 5.60 discounted to 3.348

It show up at 3.35 with 2.26 discount (first error. It should be 3.35 with 2.25 discount)

If you buy 8 of this product, the cart show a total of 26.80

If you check out, at step 2, order total show 26.78

It seems that this comes from the change in includes/classes/order.php occurred from 1.5.0 to 1.5.1 (around line 573)

Not investigated the rounding error in the price showing in product page (I gues it will be in listing too).

Paolo De Dionigi
Co-maintainer of Zen Cart Italia

19 Nov 2012, 6:23 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: order total different from cart total

What are you using to discount the Product from 5.60 to 3.348 ... there are quite a few ways that discounts things ... :lookaroun

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

20 Nov 2012, 5:34 PM
#3
s_p_ike avatar

s_p_ike

Zen Follower

Join Date:
Feb 2005
Location:
Italy
Posts:
178
Plugin Contributions:
0

Re: order total different from cart total

Hi Linda, Catalog->Specials, new price (not using percentage).

Paolo De Dionigi
Co-maintainer of Zen Cart Italia

23 Nov 2012, 7:34 PM
#5
sandroweb avatar

sandroweb

New Zenner

Join Date:
Jan 2005
Location:
Como - Italia
Posts:
3
Plugin Contributions:
0

Re: order total different from cart total

Hi Wilt,
we applied the mod you wrote for s_p_ike and in his case it works but now we have another problem.
The mod works if Zen Cart makes approximation by excess, for example 3.348 that becomes 3.35
We have another case: we need to have Products Price (Gross) equal to 50 euro so we wrote 50 in Products Price (Gross) field and we selected Italian vat from Tax Class dropdown menu in order to have our Products Price (Net).
Italian vat is equal to 21% so we have:
Products Price (Gross) = 50 euro
Tax class = 21%
Products Price (Net) = 41.3223 euro
When we put 4 pieces of this product in cart it shows a total of 200 euro but If we check out, at step 2, order total shows 199.99 due to 41.32 x 4 plus vat = 199.9888 euro = 199.99

The problem is the approximation by defect.
Thank you ;-)

Staff Zen Cart Italia since 2004.

23 Nov 2012, 10:53 PM
#6
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,927
Plugin Contributions:
3

Re: order total different from cart total

Hi

I'm assuming here that you have DISPLAY_PRICE_WITH_TAX = 'true'

Seems the tax calculation re-introduces the rounding bug.

I'm testing a fix at the moment, and while I have not yet promoted it to github, heres a git patch.

From b83f21bd295c0a8ebf31bbc8efdea9d8f5907253 Mon Sep 17 00:00:00 2001
Date: Fri, 23 Nov 2012 21:47:12 +0000
Subject: [PATCH] CHANGE-399 - order total different from cart total

Adjust previous fix to take account of DISPLAY_PRICE_WITH_TAX
---
 includes/classes/order.php |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/includes/classes/order.php b/includes/classes/order.php
index 39b76bc..2023db6 100644
--- a/includes/classes/order.php
+++ b/includes/classes/order.php
@@ -439,13 +439,20 @@ class order extends base {
         $rowClass="rowOdd";
       }
       $taxRates = zen_get_multiple_tax_rates($products[$i]['tax_class_id'], $taxCountryId, $taxZoneId);
+      if (DISPLAY_PRICE_WITH_TAX == 'true')
+      {
+       $finalPrice = $products[$i]['price'] + $_SESSION['cart']->attributes_price($products[$i]['id']);
+      } else 
+      {
+       $finalPrice = zen_round($products[$i]['price'] + $_SESSION['cart']->attributes_price($products[$i]['id']), $decimals);
+      }
       $this->products[$index] = array('qty' => $products[$i]['quantity'],
                                       'name' => $products[$i]['name'],
                                       'model' => $products[$i]['model'],
                                       'tax_groups'=>$taxRates,
                                       'tax_description' => zen_get_tax_description($products[$i]['tax_class_id'], $taxCountryId, $taxZoneId),
                                       'price' => $products[$i]['price'],
-                                      'final_price' => zen_round($products[$i]['price'] + $_SESSION['cart']->attributes_price($products[$i]['id']), $decimals),
+                                      'final_price' => $finalPrice,
                                       'onetime_charges' => $_SESSION['cart']->attributes_price_onetime_charges($products[$i]['id'], $products[$i]['quantity']),
                                       'weight' => $products[$i]['weight'],
                                       'products_priced_by_attribute' => $products[$i]['products_priced_by_attribute'],
-- 
1.7.10.4

Edit
Our CI server just returned results, and the patch above does not seem to break our current tests.
Thats not to say it doesn't break something we are not testing for though :)

27 Nov 2012, 7:24 PM
#7
sandroweb avatar

sandroweb

New Zenner

Join Date:
Jan 2005
Location:
Como - Italia
Posts:
3
Plugin Contributions:
0

Re: order total different from cart total

Hi Wilt,
sorry for the delay but we were testing and these are the results:

in the previous case we have
DISPLAY_PRICE_WITH_TAX = 'true'
Tax class = 21%
and after your mod everything is ok, we have 200 euro.

Then we changed some values:
With DISPLAY_PRICE_WITH_TAX = 'true'
Tax class = none
product price gross = product price net = 3.348 euro
We added 8 pieces of this product in cart, as s_p_ike wrote before.
Result: in the shopping cart page it shows a subtotal of 26.80 euro while if we check out, at step 2, subtotal shows 26.78 euro.

With DISPLAY_PRICE_WITH_TAX = 'false'
Tax class = none
product price gross = product price net = 3.348 euro
We added 8 pieces of this product in cart.
Result: everywhere (shopping cart page and at step 2) we have a subtotal of 26,80 euro, and it is correct.

With DISPLAY_PRICE_WITH_TAX = 'false'
Tax class = 21%
product price gross = 4.0511 euro
product price net = 3.348 euro
We added 8 pieces of this product in cart.
Result: everywhere (shopping cart page and at step 2) we have a subtotal of 26,80 euro and it is correct.

Best regards

Staff Zen Cart Italia since 2004.

27 Nov 2012, 9:33 PM
#8
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,927
Plugin Contributions:
3

Re: order total different from cart total

Hi,

I made a slight adjustment to previous code fix

-      if (DISPLAY_PRICE_WITH_TAX == 'true')
+      
+      if (DISPLAY_PRICE_WITH_TAX == 'true' && $products[$i]['tax_class_id'] != 0)
       {
28 Nov 2012, 4:29 PM
#9
sandroweb avatar

sandroweb

New Zenner

Join Date:
Jan 2005
Location:
Como - Italia
Posts:
3
Plugin Contributions:
0

Re: order total different from cart total

Hi Wilt,
now the case DISPLAY_PRICE_WITH_TAX = 'true' and Tax class = none is correct, thank you!

We tested the other cases again but now there is an error when we have:
DISPLAY_PRICE_WITH_TAX = 'true'
Tax class = 21%
product price net = 3.348 euro
product price gross = 4.0511 euro
We added 8 pieces of this product in cart.
Result: in the shopping cart page it shows a subtotal of 32.40 euro while if we check out, at step 2, subtotal shows 32.41 euro.

Best regards

Staff Zen Cart Italia since 2004.

9 Dec 2012, 8:29 AM
#10
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,927
Plugin Contributions:
3

Re: order total different from cart total

Hi,

The problem is that the changes here are really just band aids against a deeper problem with the way the order class calculates the taxes.

I'm currently working on refactoring that, and things are looking good so far.

Will let you know when I'm done