Correct price for a quantity of products
Is there any way to make sure that e.g. 10 pcs of a products that "seems" to cost 1.25 (reality 1.2534) becomes 12.50 and NOT 12.53.
By introducing zen_round() to the function zen_add_tax($price, $tax) I get the shopping cart ok, but subtotal and thereby total still hangs (erroneously) on to the decimals.... I use 1.3.9h
Erroneous rounding of item price
10 pcs of a products that "seems" to cost 1.25 (reality 1.2534) should become 12.50 and NOT 12.53.
By introducing zen_round() to the function zen_add_tax($price, $tax) I get the shopping cart ok, but subtotal and thereby total still hangs (erroneously) on to the decimals.... I use 1.3.9h
Re: Erroneous rounding of item price
How much are 3 suppose to be?
How much are 5 suppose to be?
How much are 7 suppose to be? :unsure:
Re: Erroneous rounding of item price
I used zen_round() when testing - hopefully it's working correctly.... The point was that the "extra" digits should be rounded BEFORE multiplying with quantity! As a reply to the "wise man":no:: as far as I know 1-4 goes down, 6-9 goes up and 5 goes to even.
Re: Correct price for a quantity of products
Re: Correct price for a quantity of products
You might try to directly answer the questions on post #3 ... it would help to know ...
Re: Correct price for a quantity of products
What did I not answer?
Quote:
as far as I know 1-4 goes down, 6-9 goes up and 5 goes to even
0.1-0.4 => 0
0.6-0.9 => 1
0.5 => 0
Re: Correct price for a quantity of products
Ajeh was talking about quantities, not "how does rounding work".
ie: if you have 3 items at 1.2534 or have 45 items at 1.2534, how exactly do you think the rounding should work then? There's a huge difference when you look at it that way.
Re: Correct price for a quantity of products
There's NO DIFFERENCE: Quite simple, if the product price is shown as 1.25 (although adding tax has made it actually 1.2543) it's 1.25 - it doesn't matter how many products you buy, the unit price should be 1.25! (3pcs 3.75, 45pcs 56.25)
The problem arises, as you well know, because it stores the price without taxes and then adds the tax "on the fly" if so requested. So if the price (with no tax) contains cents and the tax is a number (almost anything but a 100%) you get fractions of a cent - e.g. 1.11 * 1.13 (13% tax) = 1.2543 AND this is shown as a unit price of 1.25 when you look at the product (as it should)! BUT when you buy 10 pcs, the price is suddenly 12.54:frusty: - not much, but it makes the shop look "adequate" not good!
And I managed to get it half right - as I said:
Quote:
By introducing zen_round() to the function zen_add_tax($price, $tax) I get the shopping cart ok, but subtotal and thereby total still hangs (erroneously) on to the decimals.
PS. Nice that you "wise" guys stick together....
Re: Correct price for a quantity of products
PPS. THE POINT being that if the price is defined to have e.g. 2 decimals, that should determine the rounding - I mean that's why it's there, isn't it?