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).
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
Re: order total different from cart total
Hi Linda, Catalog->Specials, new price (not using percentage).
Re: order total different from cart total
Hi,
Please see
https://github.com/zencart/zencart/c...a8feb91d14c8dc
to see if that helps.
Note there is also
https://github.com/zencart/zencart/c...bfedf4a342d0de
but that just fixes the fact that I hardcoded the rounding in the initial fix.
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 ;-)
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.
Code:
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 :)
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
Re: order total different from cart total
Hi,
I made a slight adjustment to previous code fix
PHP Code:
- if (DISPLAY_PRICE_WITH_TAX == 'true')
+
+ if (DISPLAY_PRICE_WITH_TAX == 'true' && $products[$i]['tax_class_id'] != 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
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