Zen Cart Logo
Forums / Bug Reports / Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

Views: 2,593

Results 1 to 12 of 12
23 Sep 2012, 4:13 AM
#1
lmax401 avatar

lmax401

New Zenner

Join Date:
Jan 2007
Location:
Louisburg, Kansas
Posts:
27
Plugin Contributions:
0

Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

Trying to complete the upgrade from v139h to v150 and having rounding issue in the shopping cart.
v150 Site: maxwelldirect.com/store2
Item page example: http://www.maxwelldirect.com/store2/index.php?main_page=product_info&products_id=429
The product is: 225: Weekly Time Card
The prices displayed on the product info page are correct.
250= $24.50
500= $38.50
1000= $63.88

Price Manager Settings for this item:
Price Each: .098, Qty Min: 250, Qty Units: 1, Price by Attribute: No
Discount Type: Percentage
250= 0.00,
500= 21.4286%
1000= 34.8214%

Priced Displayed in the Shopping Cart:
250= $25.00
500= $40.00
1000= $60.00

If the currency decimal is changed from 2 to 3 or 4, different amounts will show for both and not what they are suppose to be.

Do not have this problem in the current version v139h.

Please advise

25 Sep 2012, 1:14 AM
#2
lmax401 avatar

lmax401

New Zenner

Join Date:
Jan 2007
Location:
Louisburg, Kansas
Posts:
27
Plugin Contributions:
0

Re: Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

Could sure use some help with this problem or is this something that can not be fixed in v150?

25 Sep 2012, 1:42 AM
#3
ajeh avatar

ajeh

Oba-san

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

Re: Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

I am looking into this right now and will be posting a solution as soon as possible ...

Sorry to keep you hanging ... but I have reproduced this ... I just need to ensure the fix does not trigger other issues somewhere else ...

Thanks for your patience on this ... :cool:

22 Oct 2012, 6:22 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

What happens if you edit the file:
/includes/classes/shopping_cart.php

and around line 852 change the code from:

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

to read:

[B]//[/B]      $this->total += zen_round(zen_add_tax($productTotal, $products_tax), $decimalPlaces) * $qty;
[B]      $this->total += (zen_add_tax($productTotal, $products_tax)) * $qty;
//[/B]      $this->total += zen_round(zen_add_tax($totalOnetimeCharge, $products_tax), $decimalPlaces);
[B]      $this->total += (zen_add_tax($totalOnetimeCharge, $products_tax));
[/B]      $this->free_shipping_price += zen_round(zen_add_tax($freeShippingTotal, $products_tax), $decimalPlaces) * $qty;

And if you change the code in the file:
/includes/modules/pages/shopping_cart/header_php

to have the code:

[B]//echo 'I AM HEADER_PHP final_price: ' . $ppe . '<br>';[/B]
[B]//[/B]  $ppe = zen_round(zen_add_tax($ppe, zen_get_tax_rate($products[$i]['tax_class_id'])), $currencies->get_decimal_places($_SESSION['currency']));
[B]//[/B] Ajeh - Tax fix?
[B]  $ppe = ((zen_add_tax($ppe, zen_get_tax_rate($products[$i]['tax_class_id'])) ));
[/B]

Does this fix the display on the shopping_cart.php?

Does your checkout_payment and checkout_confirmation work right?

23 Oct 2012, 1:09 PM
#5
lmax401 avatar

lmax401

New Zenner

Join Date:
Jan 2007
Location:
Louisburg, Kansas
Posts:
27
Plugin Contributions:
0

Re: Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

Ajeh:
Thank you again for following up on this.
Have applied the changes you sent and the shopping cart is now displaying the correct prices however, the Sub-Total line amount at the bottom of the box is not correct.
Example:
250 = $24.50, Sub-Total is showing $49.50
500 = $38.50, Sub-Total = $78.50
1000 = $63.88, Sub-Total = $123.88

Have no taxes installed so, I can not determine where the additional amount is coming from.
The cart goes back to the original problem after removing the updates above.

23 Oct 2012, 4:37 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

Do you have these changes on your server right now?

25 Oct 2012, 3:45 AM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

Something doesn't seem right on the updates ...

Let me go through my files again tomorrow and see if anything is missing it is almost like you have duplicate code in one of the files, such as the shopping_cart.php class ...

Make sure the comment lines are in there on the old code and not just the new lines ...

26 Oct 2012, 1:12 AM
#9
lmax401 avatar

lmax401

New Zenner

Join Date:
Jan 2007
Location:
Louisburg, Kansas
Posts:
27
Plugin Contributions:
0

Re: Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

Ajeh,
I reinstalled the changes you sent and that fixed the problem with the Sub-Total however when running through a test order the rounding problem appeared again. Have attache two screen shots for you.
In screen shot one, the Your Total amount is $60.00 but, notice the Shopping Cart price of $63.88 which is the correct price.
Thank you again for your help on this.
SteveAttachment 11355Attachment 11356

26 Oct 2012, 3:56 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

What a difference an update makes ...

I am testing on v1.5.1 and there is a change to the orders.php class in v1.5.1 ...

If you download the Zen Cart v1.5.1 ... then copy the file:
/includes/classes/orders.php

to your v1.5.0 site, you will find that the checkout_ pages now work correctly ...

See if that doesn't get things back on track for you ...

NOTE: Zen Cart v1.5.1 does NOT update the other changes that you had to add for the shopping_cart.php class and shopping_cart header.php ...

27 Nov 2012, 7:53 PM
#11
dab avatar

dab

New Zenner

Join Date:
Jan 2007
Location:
UK
Posts:
62
Plugin Contributions:
0

Re: Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

I am also having an issue with the calculated totals on ZC 1.50, it's not really bad, as the end total is correct, just confusing.

I have an item that is £1.85 each, and has a quantity discount set in the attribute controller of 5% for more than 100 items. So the product page shows the discounted price in the table as £1.76, although unrounded it is actually 1.7575.

So if someone orders 200 items, then 200 x 1.76 = 352.00
This is what shows in the basket, and all the checkout stages up to stage 3, when it dispays:

200 x Item £351.50
Sub-Total: £352.00
Postage £ 0.00
Total £352.00

So the 352.00 total is correct (in my mind), but the £351.50 is a little confusing (even if it doesn't affect the total).

The difference seems to come from the percent discount, and where the rounding is done, as 200 x 1.7575 = 351.50

I have tried the order.php file from 1.51, and it is more consistent - but it makes the sub-total and total £351.50

Is it the intention to do the rounding for the percent discount per total items (as 1.51), or per item (partly as 1.50). If it's per item, then the 1.50 version is closer, but slightly wrong.

28 Nov 2012, 2:28 AM
#12
lmax401 avatar

lmax401

New Zenner

Join Date:
Jan 2007
Location:
Louisburg, Kansas
Posts:
27
Plugin Contributions:
0

Re: Shopping Cart Rounding Problem with products priced at 0.098 and qty pricing

Linda,
Since our last email my old website was hacked to the point it was blocked by Google. The site was so infected, had to have the hosting company swipe or as they described it "Nuke It" so now, I am starting over with v.151.

Will implement the changes stated above and respond.
Thank you again for your help.