If this is your first visit, check our documentation. To post, register or login.
Forums / Bug Reports / [OPEN CHANGE-323]rounding error with attributes and salemaker

[OPEN CHANGE-323]rounding error with attributes and salemaker

Started by lankeeyankee on 9 Sep 2012, 12:13 AM · Views: 2,597

Results 1 to 10 of 10
9 Sep 2012, 12:13 AM
#1
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

[OPEN CHANGE-323]rounding error with attributes and salemaker

This happens with 1.3.9h or 1.5 on fresh install with no modules or modifications. If you add a product with multiple attributes and price the product by attributes and the product is on sale (may happen on special, too, but haven't checked).

Salemaker must be set to: Apply SaleDeduction to Specials Price - Otherwise Apply to Price, or: Ignore SaleCondition - No Sale Applied When Special Exists. If it's set to Ignore Specials Price - Apply to Product Price and Replace Special (and there are no specials running) the price comes out at $6.38 for some reason, but that's for a different bug report.:smile:

All attributes are radio buttons.

At least 2 attributes have prices and one is added to the base price but the others are not. So, an example would be a shirt, with attributes:

size : S ($5.88), M ($6.00), L ($6.50) (all marked as add to base price with S marked default)(notice, too, no plus signs are used since this is the base price but I don't think this will matter)
color: red, blue, green (no prices)
neck: crew (+$0.00), V (+$.50)

All attributes have Apply Discounts Used
by Product Special/Sale: Yes

A sale is set up for 5% off.

So, you select a Small, red shirt with V neck. The total price should be:

zen_round(5.88 * .95) + zen_round(.5 * .95) = (5.59) + (.48) = 6.07

But what is happening is this:

(5.88 * .95) + (.5 * .95) = (5.586) + (.475) = zen_round(6.061) = 6.06

On the product info page the correct sale prices are displayed: $5.59 and $.48 which added together equals $6.07, but when added to cart and in the order it's $6.06.

So it's rounding after adding all discounted attribute prices together instead of before adding them together which is off by a penny in this case and if someone is buying 100 we're giving them $1 off and it throws the books out of whack.

Please let me know if you need any more details.


Zen Cart and it's community are the best!!

25 Sep 2012, 1:03 PM
#2
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: [OPEN CHANGE-323]rounding error with attributes and salemaker

Any ideas on this? I really need to figure this out since we sell high volume of low value products and it's really throwing things out of whack. If more info is needed please let me know.


Zen Cart and it's community are the best!!

13 Nov 2012, 7:35 PM
#3
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: [OPEN CHANGE-323]rounding error with attributes and salemaker

Is there any fix to share yet? We just changed to Paypal Payments Pro and found that this error is causing checkout errors and orders are not able to go through. The checkout error message is ```html
Invalid Data - This transaction has been completed, but the total of items in the cart did not match the total of all items.


Even though the cart is showing the correct price I think Paypal is expecting an extra penny on a product because of this rounding error. I have had to switch back to First Data until this is resolved, so please let me know if there is a fix yet because I urgently need to get this working correctly.


Zen Cart and it's community are the best!!

2 Dec 2012, 5:46 AM
#5
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: [OPEN CHANGE-323]rounding error with attributes and salemaker

It looks like it's working although I had to comment out this line

while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
        //  $productTotal = 0; //this line commented out to work
          $adjust_downloads ++;

If it wasn't commented out the cart subtotal was displaying $0.00. Will this break something that I am not seeing?


Zen Cart and it's community are the best!!

3 Dec 2012, 9:09 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: [OPEN CHANGE-323]rounding error with attributes and salemaker

Hmmm, probably not good to comment that out.

Is it possible to get a zipped copy of your database for some testing?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Dec 2012, 4:35 PM
#7
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: [OPEN CHANGE-323]rounding error with attributes and salemaker

I will try it on a stock install, it's possible that one of my mods or changes is clashing. If so I will have to isolate the conflict. I am curious about what commenting out that line would do since everything appears to work as expected, the order total is correct, it shows up correctly in the db.

I will report back with my results.

Thanks again for addressing this!!


Zen Cart and it's community are the best!!

4 Jan 2013, 12:41 AM
#8
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: [OPEN CHANGE-323]rounding error with attributes and salemaker

So I looked through my many, many mod changes and can't see where this has caused the reported conflict without the commenting out. I have run this repeatedly and can't see any detrimental effects in the order side or admin side, Paypal side looks good, too. What are the consequences of commenting out that line that I am not seeing? I don't want to break anything on the production site since this is our main revenue stream and I am super cautious about making changes on the live site.

Thanks!!


Zen Cart and it's community are the best!!

4 Jan 2013, 4:08 PM
#9
wilt avatar

wilt

Oji-san

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

Re: [OPEN CHANGE-323]rounding error with attributes and salemaker

Hi,

I've looked over the code I did for shopping_cart.php, and the line you mention is definitely required for proper functioning, and I am at a loss as to why it needs to be commented out for the code to work for you.

Could you send me a copy of your shopping_cart.php file, so I can compare to mine.

Thanks

4 Jan 2013, 5:30 PM
#10
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: [OPEN CHANGE-323]rounding error with attributes and salemaker

Actually, of course, right after I posted that I went back and looked again and found out what was going on. Some of the mods are changing the same file and it can be tricky to untangle what's what. With a new crack at it with my "coding hat" firmly in place and no distractions I got it all sorted without uncommenting that line so it's all working correctly now with your changes in place.

Thanks again, Wilt! You saved the day with getting this working with Paypal Payments Pro.:cheers:


Zen Cart and it's community are the best!!