Page 1 of 1
Auto Update Currency, change the rate source?
Posted: Wed May 29, 2013 3:58 pm
by James_K
Hi
We like the "Auto Update Currency" feature, but we have a slight problem with it, our local currency is GBP, but we sell a lot of items throughout Europe, so offering Euro rates helps our customers, but the rate that open cart uses on a daily basis differs from the exchange rate that PayPal (our merchant gateway) offer to exchange the Euros back into GBP.
Is there a way to bring the two rates in line, or change the update source for opencart to be the same as PayPal?
Re: Auto Update Currency, change the rate source?
Posted: Wed May 29, 2013 9:22 pm
by James_K
Just worked out that it is a difference of 2.9% the wrong way, so that will soon add up!

Re: Auto Update Currency, change the rate source?
Posted: Wed May 29, 2013 10:32 pm
by pprmkr
At line 131 of admin/model/localisation/currency.php you find the value returned by finance.yahoo.com :
Code: Select all
$value = utf8_substr($line, 11, 6);
Result:
GBPEUR=X,1.1688
GBPUSD=X,1.5131
After that you could substract the 2.9% Paypal takes as provision.
Code: Select all
$value = ( $value / 102.9 * 100 );
For instance:
1 GBP = 1.1688 EUR
After calculation:
1 GBP = 1,13586 EUR
Re: Auto Update Currency, change the rate source?
Posted: Wed May 29, 2013 10:44 pm
by James_K
thanks!
How do i force open cart to update the rate so i can see if the code has worked?
Re: Auto Update Currency, change the rate source?
Posted: Wed May 29, 2013 10:45 pm
by rph
I believe it's either logging into admin or going into the store settings.
Re: Auto Update Currency, change the rate source?
Posted: Wed May 29, 2013 10:55 pm
by James_K
hmm. have logged in and checked under site settings and currencies - but can not see anything...
Re: Auto Update Currency, change the rate source?
Posted: Wed May 29, 2013 11:08 pm
by James_K
this is what i have added, am i right?
Code: Select all
foreach ($lines as $line) {
$currency = utf8_substr($line, 4, 3);
$value = utf8_substr($line, 11, 6);
$value = ( $value / 102.9 * 100 );
Re: Auto Update Currency, change the rate source?
Posted: Wed May 29, 2013 11:12 pm
by pprmkr
When in System - Settings - Store: Local -> Auto Update Currency: is set to Yes, just click on Dashboard to update the currencies.
Re: Auto Update Currency, change the rate source?
Posted: Wed May 29, 2013 11:22 pm
by James_K
pprmkr wrote:When in System - Settings - Store: Local -> Auto Update Currency: is set to Yes, just click on Dashboard to update the currencies.
Tried that, still no change in the admin section or on the store front.
Also tried switching the Auto Update Currency Off -> save then switch it back On, no change.
I can wait till tomorrow to see if it changes the rates then - just keen to see live changes

Re: Auto Update Currency, change the rate source?
Posted: Wed May 29, 2013 11:56 pm
by rph
It only updates once a day. You can force update the currency by editing /admin/controller/common/home.php and changing:
Code: Select all
$this->model_localisation_currency->updateCurrencies();
to:
Code: Select all
$this->model_localisation_currency->updateCurrencies(true);
Re: Auto Update Currency, change the rate source?
Posted: Thu May 30, 2013 1:41 am
by James_K
Great that got the currency to update, but the formula was the wrong way round:
Code: Select all
foreach ($lines as $line) {
$currency = utf8_substr($line, 4, 3);
$value = utf8_substr($line, 11, 6);
$value = ( $value / 102.9 * 100 );
This would equate to current exchange rate1.1667
less 2.9% = 1.1338, so before the calculation of a product costing £100, would have been 116.67 Euros, and after the calculation would be 113.38 Euros.
So the code should be:
Code: Select all
foreach ($lines as $line) {
$currency = utf8_substr($line, 4, 3);
$value = utf8_substr($line, 11, 6);
$value = ( $value * 102.9 / 100 );
This would equate to current exchange rate1.1667
pluss 2.9% = 1.2005, so before the calculation of a product costing £100, would have been 116.67 Euros, and after the calculation would be 120.05 Euros.
So now when PayPal deduct 2.9% for their exchange of the Euros back into GBP we get £100.11
Thanks to everyone for the help on this, and i hope it helps others

Re: Auto Update Currency, change the rate source?
Posted: Tue Aug 16, 2016 2:02 am
by balloonprint
Hi, we use Opencart 2.1.0.2 and we have same problem the price in EUR should be higher then now, i tried same code in currency.php but it is not change anything at all. Could you help me with this please.
Re: Auto Update Currency, change the rate source?
Posted: Thu Aug 18, 2016 7:27 pm
by fido-x
PayPal's exchange rates are different to the official exchange rates. They designed to make money for PayPal when used to convert currencies.
The best method is to add the other currencies to your PayPal and your store, so that you can accept payment in the other currencies. That way, any loss (or profit) from exchanging currencies is borne by you and not your customer.
Re: Auto Update Currency, change the rate source?
Posted: Sun Aug 21, 2016 8:09 pm
by balloonprint
James_K wrote:Great that got the currency to update, but the formula was the wrong way round:
Code: Select all
foreach ($lines as $line) {
$currency = utf8_substr($line, 4, 3);
$value = utf8_substr($line, 11, 6);
$value = ( $value / 102.9 * 100 );
This would equate to current exchange rate1.1667
less 2.9% = 1.1338, so before the calculation of a product costing £100, would have been 116.67 Euros, and after the calculation would be 113.38 Euros.
So the code should be:
Code: Select all
foreach ($lines as $line) {
$currency = utf8_substr($line, 4, 3);
$value = utf8_substr($line, 11, 6);
$value = ( $value * 102.9 / 100 );
This would equate to current exchange rate1.1667
pluss 2.9% = 1.2005, so before the calculation of a product costing £100, would have been 116.67 Euros, and after the calculation would be 120.05 Euros.
So now when PayPal deduct 2.9% for their exchange of the Euros back into GBP we get £100.11
Thanks to everyone for the help on this, and i hope it helps others

Can you advise me please what code i can use for Opencart 2.1.0.2? I tried to do what you said but it is not work.