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

osCommerce

The e-commerce.

# The amount of "Total" in Shopping cart is not correct.

## Recommended Posts

I know this problem is caused by decimal places.

I think the shopping cart is not using 2 decimal place to calculate but using

For example ,79.99EUR * 10 =799.93 but not 799.90EUR.

##### Share on other sites

Everyone is changing the world.

Everyone is a world.

For everyone needs my help, PM or email if I amn't online.

##### Share on other sites

I am so sorry that i cant publish my site at this moment.I dot know why ,may be caused by apache misconfiguration.

However, I went to the oscommerce demo store. http://demo.oscommerce.com/ and do some testing about the shopping cart, the problem that I mentioned is also occuring.

##### Share on other sites

OSC calculate price like that:

If USD is default currency, a product's price is \$29.99, then ten products in shopping cart will make total to \$299.90. When switch currency to EUR, OSC will calculate total price with these steps below:

29.99 *10 = 299.90, then 299.90*0.73460001(exchange rate between USD and EUR) = 220.31

So if you set EUR to default currency, you will get another total price.

It depends on which currency is default.

Everyone is changing the world.

Everyone is a world.

For everyone needs my help, PM or email if I amn't online.

##### Share on other sites

can it be fixed except setting the default currency.It is because ,I would like to accept multi-currency in my store in future.

If this problem cannot be solved ,it will cause the problem of integrity between the record paypal and the record in my store.

For example,a product cost 99.99USD,and I would like to buy ten of it in EUR.

The value pass to Paypal is that , 99.99*0.73(in 2 decimal place) for item price, 10 for quality.

99.99*0.73=72.9927 , then Paypal will use 72.99 EUR to calculate the total ,72.99*10=729.90EUR which is different from 99.99*10*0.73=729.93..

Is there any way to solve this problem?If I want to solve ,I have to change the sequence of the calculation in OSC?It seems too complicated..

##### Share on other sites

can it be fixed except setting the default currency.It is because ,I would like to accept multi-currency in my store in future.

If this problem cannot be solved ,it will cause the problem of integrity between the record paypal and the record in my store.

For example,a product cost 99.99USD,and I would like to buy ten of it in EUR.

The value pass to Paypal is that , 99.99*0.73(in 2 decimal place) for item price, 10 for quality.

99.99*0.73=72.9927 , then Paypal will use 72.99 EUR to calculate the total ,72.99*10=729.90EUR which is different from 99.99*10*0.73=729.93..

Is there any way to solve this problem?If I want to solve ,I have to change the sequence of the calculation in OSC?It seems too complicated..

I think it's a big project to do this...

It requires that you are familiar with the codes structure in PHP and OSC?

Otherwise you could look for some contributions match your requirement.

Everyone is changing the world.

Everyone is a world.

For everyone needs my help, PM or email if I amn't online.

O....

##### Share on other sites

it is possible to change all the number in OSC to 2 decimal place.?

is it can not only round the number?

##### Share on other sites

it is possible to change all the number in OSC to 2 decimal place.?

is it can not only round the number?

Go to admin panel, then go to "Localization->Currencies", edit every currency's Decimal Places.

Everyone is changing the world.

Everyone is a world.

For everyone needs my help, PM or email if I amn't online.

##### Share on other sites

I have changed all the currency's Decimal Places to 2 but the problem is still occurring.

I think OSC is not using 2 decimal places when calculating the price.

I have looked into the code.

`\$shown_price = \$currencies->calculate_price(\$this->products[\$index]['final_price'], \$this->products[\$index]['tax'], \$this->products[\$index]['qty']);`

Is that the function "calculate_price" are not using 2 decimal place to calculate??

##### Share on other sites

I have changed all the currency's Decimal Places to 2 but the problem is still occurring.

I think OSC is not using 2 decimal places when calculating the price.

I have looked into the code.

`\$shown_price = \$currencies->calculate_price(\$this->products[\$index]['final_price'], \$this->products[\$index]['tax'], \$this->products[\$index]['qty']);`

Is that the function "calculate_price" are not using 2 decimal place to calculate??

I find a simple way to resolve the problem between paypal and your osc store(although it isn't the best way) that you can change one of your paypal setting named "Transaction Type", change its value from "Per Item" to "Aggregate".

Then paypal will only show total not every product.

Everyone is changing the world.

Everyone is a world.

For everyone needs my help, PM or email if I amn't online.

##### Share on other sites

I have solved the problem by modifying a piece of code in paypal_ipn.php(just modified a little bit)

The code i have modified. in line 271.

``` \$parameters['item_name_' . \$item] = \$temp_item_name;
\$parameters['amount_' . \$item] = round((\$order->products[\$i]['final_price']*\$order->products[\$i]['qty']* \$order->info['currency_value']),2);
\$parameters['tax_' . \$item] = number_format(\$tax_value, \$currencies->get_decimal_places(\$currency));
\$parameters['quantity_' . \$item] = 1;```

Yes !!!!!I solved it , I can have a sleep!

##### Share on other sites

I have solved the problem by modifying a piece of code in paypal_ipn.php(just modified a little bit)

The code i have modified. in line 271.

``` \$parameters['item_name_' . \$item] = \$temp_item_name;
\$parameters['amount_' . \$item] = round((\$order->products[\$i]['final_price']*\$order->products[\$i]['qty']* \$order->info['currency_value']),2);
\$parameters['tax_' . \$item] = number_format(\$tax_value, \$currencies->get_decimal_places(\$currency));
\$parameters['quantity_' . \$item] = 1;```

Yes !!!!!I solved it , I can have a sleep!

Congratulations!

And I think it's valuable experience between us!

Everyone is changing the world.

Everyone is a world.

For everyone needs my help, PM or email if I amn't online.

#### Archived

This topic is now archived and is closed to further replies.

×
×
• Create New...