Rounding errors in order/cart totals?
- sloanthrasher
-
Topic Author
- Offline
Less
More
13 years 4 months ago - 13 years 4 months ago #111844
by sloanthrasher
Sloan Thrasher
Rounding errors in order/cart totals? was created by sloanthrasher
Hi,
I have products which are priced in fractions of a cent (USD). The site sells mostly bulk quantities of the products.
The problem is that sometimes a line item will multiply (quantity * price each) to a number with a fractional cent. For example: 50 * 0.3245 = 16.225, displayed as 16.23, or 100 * 0.34224 = 34.234, displayed as 34.23. If there are several items like this in the cart, the total is sometimes off a cent or two.
Where in the code will I find the code that calculates the total for the cart, and for the order?
Thanks!
Sloan
I have products which are priced in fractions of a cent (USD). The site sells mostly bulk quantities of the products.
The problem is that sometimes a line item will multiply (quantity * price each) to a number with a fractional cent. For example: 50 * 0.3245 = 16.225, displayed as 16.23, or 100 * 0.34224 = 34.234, displayed as 34.23. If there are several items like this in the cart, the total is sometimes off a cent or two.
Where in the code will I find the code that calculates the total for the cart, and for the order?
Thanks!
Sloan
Sloan Thrasher
Last edit: 13 years 4 months ago by sloanthrasher. Reason: mis-spelled word
Please Log in or Create an account to join the conversation.
13 years 4 months ago #111878
by Eliot
Replied by Eliot on topic Rounding errors in order/cart totals?
Hi Sloan,
Actually, Hikashop Was doing that kind of rounding before but people were complaining because total wasn't exact.
What the hikashop system is doing now is calculate the perfect result for each product (rounded on display but not in our calculation) and calculate the exact total of the order.
It means that when we calculate the total of your orders, we use the exacts price of your product and make a rounding only on the very final price.
So the price displayed is the right one.
However, if you really want to make some round, you can take a look at the function quantityPrices in currency.php in administrator/components/com_hikashop/classes
Actually, Hikashop Was doing that kind of rounding before but people were complaining because total wasn't exact.
What the hikashop system is doing now is calculate the perfect result for each product (rounded on display but not in our calculation) and calculate the exact total of the order.
It means that when we calculate the total of your orders, we use the exacts price of your product and make a rounding only on the very final price.
So the price displayed is the right one.
However, if you really want to make some round, you can take a look at the function quantityPrices in currency.php in administrator/components/com_hikashop/classes
The following user(s) said Thank You: sloanthrasher
Please Log in or Create an account to join the conversation.
- sloanthrasher
-
Topic Author
- Offline
13 years 4 months ago #111886
by sloanthrasher
Sloan Thrasher
Replied by sloanthrasher on topic Rounding errors in order/cart totals?
Thanks Eliot.
I made the changes in quantityPrice, not quantityPrices, since that's where the quantity and price were multiplied. Is that correct?
Thanks!
I made the changes in quantityPrice, not quantityPrices, since that's where the quantity and price were multiplied. Is that correct?
Thanks!
Sloan Thrasher
Please Log in or Create an account to join the conversation.
13 years 4 months ago #111888
by nicolas
Replied by nicolas on topic Rounding errors in order/cart totals?
yes.
Please Log in or Create an account to join the conversation.
Time to create page: 0.056 seconds