Rounding errors in order/cart totals?

  • Posts: 43
  • Thank you received: 0
11 years 4 months ago #111844

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


Sloan Thrasher
Last edit: 11 years 4 months ago by sloanthrasher. Reason: mis-spelled word

Please Log in or Create an account to join the conversation.

  • Posts: 2334
  • Thank you received: 403
11 years 4 months ago #111878

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

The following user(s) said Thank You: sloanthrasher

Please Log in or Create an account to join the conversation.

  • Posts: 43
  • Thank you received: 0
11 years 4 months ago #111886

Thanks Eliot.

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.

  • Posts: 82758
  • Thank you received: 13346
  • MODERATOR
11 years 4 months ago #111888

yes.

Please Log in or Create an account to join the conversation.

Time to create page: 0.079 seconds
Powered by Kunena Forum