Suppose a website run in 4 currencies: USD, EURO, Japan YEN and South Korean won. USD is the default currency
For Product A, I set the USD price to be 19.90 USD, the opencart convert it to 14.75EURO, 2031.6 Yen and 21549 Won
It is nice that the price could be rounded to 14.99EURO, 2099Yen and 21999 Won, or 14.90EURO, 2090Yen and 21900 Won
It is quite useful for multi-currency site
For Product A, I set the USD price to be 19.90 USD, the opencart convert it to 14.75EURO, 2031.6 Yen and 21549 Won
It is nice that the price could be rounded to 14.99EURO, 2099Yen and 21999 Won, or 14.90EURO, 2090Yen and 21900 Won
It is quite useful for multi-currency site
there are 2 additional value to configure for each currency
1: to determine the currency to be round to nearest 0.01,0.1,1,10 or 100
2: to determine what value to minus to the rounded value by step 1
for example:
To round the Japanese Yen from 2031.6 to 2099, it means that the yen should be rounded to nearest 100, and minus 1 upon that
1: to determine the currency to be round to nearest 0.01,0.1,1,10 or 100
2: to determine what value to minus to the rounded value by step 1
for example:
To round the Japanese Yen from 2031.6 to 2099, it means that the yen should be rounded to nearest 100, and minus 1 upon that
Perhaps this helps?
Edit system/library/currency.php
Search for:
After that add:
Edit system/library/currency.php
Search for:
Code: Select all
if ($value) {
$value = (float)$number * $value;
} else {
$value = $number;
}
Code: Select all
switch ($this->code){
case 'KRW':
$round = 1000;
$step = -100;
break;
case 'JPY':
$round = 100;
$step = -10;
break;
case 'GBP':
case 'USD':
$round = 1;
$step = -0.1;
break;
case 'EUR':
$round = 1;
$step = -0.01;
break;
default:
$round = 0;
$step = 0;
break;
}
if ($round) {
$value = ceil($value / $round ) * $round;
}
if ($step) {
$value += $step;
}
Great!
This code helped me a lot. Simple and easily adaptable to currencies.
Anyway, I think it is better to set $round = 1 in default case, to prevent a divide by zero later on, if the admin adds a currency and forgets to make the "pretty prices correction"
This code helped me a lot. Simple and easily adaptable to currencies.
Anyway, I think it is better to set $round = 1 in default case, to prevent a divide by zero later on, if the admin adds a currency and forgets to make the "pretty prices correction"
Pak R
Well. It works OK except that it also affects the admin side :-(
For front store works eprfect, but if you have a currency with large numbers (let's say IDR as example), and round to 5.000 IDR and it's the currency of your country, all sales made in USD, EUR, AUD, etc are rounded to 5.000.
So, is there a way to use this nice code modification ONLY for front store and not for admin?
Thanks!
For front store works eprfect, but if you have a currency with large numbers (let's say IDR as example), and round to 5.000 IDR and it's the currency of your country, all sales made in USD, EUR, AUD, etc are rounded to 5.000.
So, is there a way to use this nice code modification ONLY for front store and not for admin?
Thanks!
Pak R
Hi folks!
Thanks! This helped a lot.
Though this has affected my shipping prices also and my problem is when you choose free shipping it ends up as -0,1€
/0 rounded to 0 - 0,1 = -0,1/
Can you help how to set up a limit, for example only do this if the value is over 2.
Thanks! This helped a lot.
Though this has affected my shipping prices also and my problem is when you choose free shipping it ends up as -0,1€
/0 rounded to 0 - 0,1 = -0,1/
Can you help how to set up a limit, for example only do this if the value is over 2.
Try changing:
Into:
Code: Select all
if ($round) {
$value = ceil($value / $round ) * $round;
}
if ($step) {
$value += $step;
}
Code: Select all
if ($round && $value > 2) {
$value = ceil($value / $round ) * $round;
}
if ($step && $value > 2) {
$value += $step;
}
Hello,
After running some "rounds"
e.g. I bought an extension to add fixed prices https://www.opencart.com/index.php?rout ... _id=481939 instead of opencart's default currency conversion, now I would like to go back for automatic conversion with some rounding to have nicer prices.
My problem now is that I have the option to sell with or without tax in the EU. I set up the rounding as suggested and it results nice prices on the front, but when someone registers to buy without tax (vat), he's net price is rounded again, which is unwanted.
Any help would be appreciated.
After running some "rounds"

My problem now is that I have the option to sell with or without tax in the EU. I set up the rounding as suggested and it results nice prices on the front, but when someone registers to buy without tax (vat), he's net price is rounded again, which is unwanted.
Any help would be appreciated.
Who is online
Users browsing this forum: No registered users and 5 guests