osCommerce 4 osCommerce 4 App Shop Support Services App Shop Us
• Checkout
• Get in touch

osCommerce

The e-commerce.

# Bug on little amount with taxe in shopping cart

## Recommended Posts

Hi,

I think i found a little bug in the shopping cart.

If you put a little amount for a product , ex : 1.23€ with a taxe 19.6% for example, you have 1.4711 with taxe

In catalog you take 20 products

the price display is : 1.47 for one product

Now in the shopping cart you see the total product price : 29.42EUR with taxe

And the total amount in shopping cart is : Sub total : 29.40EUR with taxe

We have a difference 0.2 EUR.

The difference between the amount is the taxe. Il 's not well calculated, because there is a difference between 2 number after the comma and 4 number after the comma. And oscommerce realise and round after 2 commas. (ex 1.7859 become 1.79)

And the total amount is based on 1.79

and the total product is based on 1.7859

Note :

-without taxe there is no problem

- with attribute price is ok for the amount for the attribute. Only the price product put a problem.

- For the big amount, the problem does'nt appear ex : 100*1.196 = 119.6 (just if the number has 3 number after the coma).

Do you have a solution, an idea to resolve this ?

Oscommerce RC2a

Regards
-----------------------------------------
Loïc

Contact me by skype for business
Contact me @gyakutsuki for an answer on the forum

##### Share on other sites

Hi,

I think i found a little bug in the shopping cart.

Could well be :)

There have been many, many discussions on this subject. Have a read of "rounding errors, anyone fixed this problem?" for a recent example. I think it's one of those things for which there is no easy answer.

##### Share on other sites

Hi,

I found a solution for resolve this problem, I don't if it's perfectly.

The problem come in classes /shopping cart with this function : calculate_price in currencies.php

I think it's a new function introduced in the latest oscommerce

To resolve

replace in classes/shopping cart this

// \$this->total += \$currencies->calculate_price(\$products_price, \$products_tax, \$qty);

\$this->total += tep_add_tax(\$products_price, \$products_tax) * \$qty;

And the calcul is ok

Regards
-----------------------------------------
Loïc

Contact me by skype for business
Contact me @gyakutsuki for an answer on the forum