# Thread: Correct price for a quantity of products

1. ## 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

2. ## 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

3. ## 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?

4. ## 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": as far as I know 1-4 goes down, 6-9 goes up and 5 goes to even.

Anybody!?

6. ## Re: Correct price for a quantity of products

You might try to directly answer the questions on post #3 ... it would help to know ...

7. ## Re: Correct price for a quantity of products

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

8. ## 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.

9. ## 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 - not much, but it makes the shop look "adequate" not good!

And I managed to get it half right - as I said:
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....

10. ## 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?

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
disjunctive-egg