Post by mrblond » Sat Jun 30, 2018 1:06 am

My Opencart version 3.0.2.0
I use Four currencies. The default is Euro. Value of All currencies is up to two decimals: 1.170000 etc.
Store prices set in Euro are also up to two decimals: 3.9800 etc.
When proceeding the checkout in Euro everything is Okay.
When proceeding the checkout in other currency, there is often error with 0.01 in the total sum. Sometimes this error is in products Sum and sometimes it is in the sum product+shipping cost. I don't have any other taxes in the checkout.

For example:
Product 1 = 3.20CHF
Product 2 = 4.58CHF
Sub-Total: 7.77CHF (wrong with -0.01)

or:
Product 1 = 5.83USD
Shipping = 0.59USD
Total: 6.41USD (wrong with -0.01)

When the sum is wrong, the checkout results in error in connecting with the payment method page.
So, Opencart can not work with other currencies aside of the default.

Why is that? How to be solved?

Active Member

Posts

Joined
Fri Oct 13, 2017 4:43 pm

Post by mrblond » Sun Jul 01, 2018 12:13 am

Actually, it is clear what is the problem but how to be solved?
This is a real bug in Opencart!?!?

The products and the shipping are listed in shopping cart (and respectively in the invoice) rounded to two decimals, which is okay.
But the Sub-total and the Total are sum of not rounded prices.
For example: Default product price: 4.98EUR and Shipping 0.50EUR, when one changes the currency to USD (1EUR=1.17USD):
in the table and invoice it is rounded:
Product 1 = 5.83USD
Shipping = 0.59USD

but Opencart sums in the background:
Product 1 = 5.8266USD + Shipping = 0.585USD and then round it in the Total=6.41USD which is different from the sum of the prices in the table which is 6.42USD.
As a result, when the checkout is confirmed, the bank module doesn't accept it and opens error page.

How to make the cart to sum the initially rounded prices which are shown in the table?

Active Member

Posts

Joined
Fri Oct 13, 2017 4:43 pm

Post by IP_CAM » Sun Jul 01, 2018 1:48 am

Well, this Extension might be of help on such:
---
Price Rounding
https://www.opencart.com/index.php?rout ... n_id=10016
---
found here:
https://www.opencart.com/index.php?rout ... arch=round
---
This always has been a potential problem, as it looks, and
according to older topics, but I never made any tests, to be able to judge.
Good Luck!
Ernie
---
Image

For Sale: Turnkey URLs with Opencart installed!
Ernie's present Opencart Testsite: http://www.velomech.ch
Attacker IP Blocks are denied from further access to my Sites!
Just contact me for more Information at: jti@jacob.ch
665 FREE OC Extension-Repositories - from OC v.1.5.x up
on the largest Opencart-Mod Github Site: https://github.com/IP-CAM
Image


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by mrblond » Sun Jul 01, 2018 5:29 am

Isn't it be easier somebody to tell me what code lines to change in some .php file?
I can't believe such a huge bug to exist and Opencart developers do nothing!
Shouldn't we tell the world that Opencart can't work with multiple currencies.

So, people, what is the solution?

Active Member

Posts

Joined
Fri Oct 13, 2017 4:43 pm

Post by mrblond » Tue Jul 03, 2018 5:27 pm

No help!

Is this bug exist in other versions?
Should I downgrade to 2.0 or wait for new version?

Active Member

Posts

Joined
Fri Oct 13, 2017 4:43 pm

Post by julian70400 » Wed Mar 06, 2019 11:52 pm

Hello, did you find a solution ?

Newbie

Posts

Joined
Thu Jun 14, 2018 10:44 pm

Post by letxobnav » Thu Mar 07, 2019 1:46 am

you might try in currency class:

change:
$amount = $value ? (float)$number * $value : (float)$number;

into:
$amount = $value ? (float)$number * round($value,(int)$decimal_place) : (float)$number;

Crystal Light Centrum Taiwan


Active Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm

Post by IP_CAM » Thu Mar 07, 2019 4:22 am

into: $amount = $value ? (float)$number * round($value,(int)$decimal_place) : (float)$number;
Well, by trying this (matched to my OC Version) in my file, it ended up
to result in one price, i.E. 400.00, shown in all currencies used. :choke:

But I also compared the v.3.1.0.0.a File with my 1.5.6.x Version File, and
found out, that my ROUNDING Code looks quite similar in v.3.x Versions.
By setting it to 1, (v.3.x - $amount, 1) (v.1.5.x - $value, 1) it results in 'even'
Numbers (00/10/20) only, and 01 - 09 will no longer exist. It a Product Price
results in 88.88 or 99.99, by a (v.3.x - $amount, 1) (v.1.5.x - $value, 1) Setting,
it will show/use 89.00 or 100.00 Values.
This might not please Germans, and others, still using single-cent Amounts,
I'm aware of that, but for some, it might be of help, if it works in your Version.
And depending on that (v.3.x - $amount, x) (v.1.5.x - $value, x) it could more
precisely meet specific needs of some of you.

Just in Case ..., and untested in later than OC 1.5.6.5_rc Versions. :D
Ernie
---
Image

Attachments

currency_rounding_opencart.jpg

currency_rounding_opencart.jpg (110.62 KiB) Viewed 149 times


For Sale: Turnkey URLs with Opencart installed!
Ernie's present Opencart Testsite: http://www.velomech.ch
Attacker IP Blocks are denied from further access to my Sites!
Just contact me for more Information at: jti@jacob.ch
665 FREE OC Extension-Repositories - from OC v.1.5.x up
on the largest Opencart-Mod Github Site: https://github.com/IP-CAM
Image


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by victorj » Thu Mar 07, 2019 4:33 am

make sure you have your currency calculated to 8 decimals.
if you have price including tax on your site, product price is calculated in 4 decimals, make sure you calculate them into 8 decimals.
to do so you wil have to alter in product table the price from 15.4 to 15.8
when entering product price enter with 8 decimals, there are mods that will allow you to input price and calculate ex tax price up to 8 decimals.

Now when prices are calculated from one currency to another or when large sums are ordered correct totals are calculated.

Koeltechnische deurrubbers eenvoudig online op maat bestellen.
Alle niet stekplichtige onderdelen zoals scharnieren, sloten, randverwarming en verlichting voor alle typen koelingen en vriezers.
https://koelcel-onderdelen.com

Koeltechnische deurrubbers eenvoudig online op maat bestellen.
Eigen productie en snelle levering.
https://123-deurrubbers.com


User avatar
Expert Member

Posts

Joined
Sat Jun 25, 2011 4:09 am
Location - Alkmaar Holland

Post by letxobnav » Thu Mar 07, 2019 8:47 am

I am using 3.0.2.0.
My default currency is Taiwan dollar with 0 decimal places.
JPY is set to 0 decimal places.
All others have 2 decimal places.

so far with

Code: Select all

$amount = $value ? (float)$number * round($value,(int)$decimal_place) : (float)$number;
all non-default currencies, USD,GBP,EURO,JPY seem ok with regard to rounding.

I guess you need to round the numbers to the decimals you display before using them in the calculations.

I must admit, I do not use the tax classes (my prices include those) so you may have to double check if you do.

Crystal Light Centrum Taiwan


Active Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm

Post by letxobnav » Thu Mar 07, 2019 8:53 am

to be sure, I am talking about the $amount calculation:

Code: Select all

$amount = $value ? (float)$number * round($value,(int)$decimal_place) : (float)$number;
not the number_format call:

Code: Select all

$string .= number_format($amount, (int)$decimal_place, $this->language->get('decimal_point'), $this->language->get('thousand_point'));
which comes later.

Crystal Light Centrum Taiwan


Active Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm

Post by julian70400 » Thu Mar 07, 2019 5:59 pm

letxobnav wrote:
Thu Mar 07, 2019 1:46 am
you might try in currency class:

change:
$amount = $value ? (float)$number * $value : (float)$number;

into:
$amount = $value ? (float)$number * round($value,(int)$decimal_place) : (float)$number;
Hello,

Are you answering this to me ? If yes, in which file ?

Newbie

Posts

Joined
Thu Jun 14, 2018 10:44 pm

Post by letxobnav » Thu Mar 07, 2019 6:19 pm

system/library/cart/currency.php

Crystal Light Centrum Taiwan


Active Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Who is online

Users browsing this forum: No registered users and 9 guests