Dear Sir/Madam,
I am new to opencart, I change the default currency to my hometown currency. I read through the forum and know that the frequency of the currency update is once a day. How can I speed up the update to twice a day or immediately?
Best regards,
Kelvin.
I am new to opencart, I change the default currency to my hometown currency. I read through the forum and know that the frequency of the currency update is once a day. How can I speed up the update to twice a day or immediately?
Best regards,
Kelvin.
Buy all of the banks, wait for escrows to close, walk in and change the policy. Government agencies pose additional steps, most cannot be bought. Rollover times in such financial centers as in London and New York are on lock-step schedules, much as we began with Greenwich Observatory and added the International Date Line, then ran bank deposits and debits through the couple of hours starting local or regional midnight, then had to reckon with international banking. You are quite free to reset your watch or car clock and look at them as often as you wish. But OC follows banking.
It will show you times in an offset, but it will update according to whatever times updates are done among financial institutions, for different currencies at exchange rates at times that apply for your own country. You let it update or not. You set your own clock to suit yourself.
Ignore everything Butte says because it is just rambling.
Currencies are updated based on 1 of 2 conditions.
1. When you add a new currency, they all get updated immediately
2. When you load your admin dashboard, they all get updated, but only once every 24 hours.
You can easily force it to happen everytime you load your admin dashboard by changing this:
1. EDIT: admin/controller/common/home.php
2. FIND:
3. REPLACE WITH:
But the problem is that the updatecurrency system in general only works if you login to the admin. If you don't check your admin for days at a time, then the currencies won't update. So this should really be moved to the catalog side and have it auto-update once every X hours when someone loads the homepage or something. This can be done by doing the following:
1. EDIT: catalog/controller/common/header.php
2. FIND:
3. AFTER, ADD:
4. THEN FIND:
5. AFTER, ADD:
Change the '-1 day' part to something more often like
'-3 hour'
I wouldn't recommend doing it immediately as it can cause a short delay each time they are updated.. but once every couple hours should be fine.
http://www.php.net/manual/sr/datetime.f ... lative.php
Currencies are updated based on 1 of 2 conditions.
1. When you add a new currency, they all get updated immediately
2. When you load your admin dashboard, they all get updated, but only once every 24 hours.
You can easily force it to happen everytime you load your admin dashboard by changing this:
1. EDIT: admin/controller/common/home.php
2. FIND:
Code: Select all
$this->model_localisation_currency->updateCurrencies();
Code: Select all
$this->model_localisation_currency->updateCurrencies(true);
1. EDIT: catalog/controller/common/header.php
2. FIND:
Code: Select all
class ControllerCommonHeader extends Controller {
Code: Select all
public function updateCurrencies($force = false) {
if (extension_loaded('curl')) {
$data = array();
if ($force) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "'");
} else {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified < '" . $this->db->escape(date('Y-m-d H:i:s', strtotime('-1 day'))) . "'");
}
foreach ($query->rows as $result) {
$data[] = $this->config->get('config_currency') . $result['code'] . '=X';
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($curl);
curl_close($curl);
$lines = explode("\n", trim($content));
foreach ($lines as $line) {
$currency = utf8_substr($line, 4, 3);
$value = utf8_substr($line, 11, 6);
if ((float)$value) {
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (float)$value . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($currency) . "'");
}
}
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'");
$this->cache->delete('currency');
}
}
Code: Select all
protected function index() {
Code: Select all
$this->updateCurrencies();
Change the '-1 day' part to something more often like
'-3 hour'
I wouldn't recommend doing it immediately as it can cause a short delay each time they are updated.. but once every couple hours should be fine.
http://www.php.net/manual/sr/datetime.f ... lative.php
The question spoke in part to (money in) the banking end of showing customers what to expect, and in part to (code) setting the frequency of spot-sampling fluctuations that do not control. The question accordingly has two answers, one not in code, one in code.
There is no "one" exchange rate, even daily, for a currency-pair. A customer will pay the exchange rate decided by the payment portal, not the one shown by OC. OC shows customers spot-sampled approximations of what will be transaction portals' own usually only daily or twice-daily averaged and hedged exchange updates, before the portals' own credits and debits go through ordinary banks' midnight processing of credits and debits at likewise averaged and hedged rates, all of which are keyed to the fewer central banks' and fewer yet huge central banks' exchange rates. Transaction fees are added to exchange rates for the sake of both safety and profit; by transaction processors, by banks, by central banks, and by huge central banks.
However often you set OC to spot-check, that value will not override what the portals and banks do.
For example, one portal, one exchange dealer, European Central Bank, and World Bank . . .
https://www.paypal.com/us/webapps/helpc ... 2900&m=SRE
PAYPAL:
Here’s how we set our exchange rate:
We receive a wholesale rate quote from our bank twice a day and add 2.5% to determine the retail foreign exchange rate to apply to transactions that involve a currency conversion.
Our currency exchange rates are competitive with conversion rates used by banks and by currency exchanges.
When you withdraw money from your PayPal account to your local bank account, we automatically convert the money into the local currency at the time of the withdrawal request.
OTHER:
http://www.oanda.com/help/how-to-read-c ... tenUpdated
When possible, we take the average of prices over the last 24 hours and use these averages to update the rate every day at 22:00 UTC (Coordinated Universal Time).
We do not take market closing prices as the "average" price. Instead we take the average from all our collected data over a 24—hour period, reflecting the fact that the foreign exchange market never really "closes" on a global basis. However, market activity is lower on weekends and holidays, so the number of prices varies from day to day. Our Rates are rounded to up to five significant digits, with a few exceptions.
EUROPEAN CENTRAL BANK:
http://www.ecb.europa.eu/stats/exchange ... ex.en.html
Euro foreign exchange reference rates. The reference rates are usually updated by 3 p.m. C.E.T. The reference rates are usually updated by 3 p.m. C.E.T. They are based on a regular daily concertation procedure between central banks across Europe and worldwide, which normally takes place at 2.15 p.m. CET.
WORLD BANK:
http://data.worldbank.org/indicator/PA.NUS.FCRF
Official exchange rate refers to the exchange rate determined by national authorities or to the rate determined in the legally sanctioned exchange market. It is calculated as an annual average based on monthly averages (local currency units relative to the U.S. dollar).
There is no "one" exchange rate, even daily, for a currency-pair. A customer will pay the exchange rate decided by the payment portal, not the one shown by OC. OC shows customers spot-sampled approximations of what will be transaction portals' own usually only daily or twice-daily averaged and hedged exchange updates, before the portals' own credits and debits go through ordinary banks' midnight processing of credits and debits at likewise averaged and hedged rates, all of which are keyed to the fewer central banks' and fewer yet huge central banks' exchange rates. Transaction fees are added to exchange rates for the sake of both safety and profit; by transaction processors, by banks, by central banks, and by huge central banks.
However often you set OC to spot-check, that value will not override what the portals and banks do.
For example, one portal, one exchange dealer, European Central Bank, and World Bank . . .
https://www.paypal.com/us/webapps/helpc ... 2900&m=SRE
PAYPAL:
Here’s how we set our exchange rate:
We receive a wholesale rate quote from our bank twice a day and add 2.5% to determine the retail foreign exchange rate to apply to transactions that involve a currency conversion.
Our currency exchange rates are competitive with conversion rates used by banks and by currency exchanges.
When you withdraw money from your PayPal account to your local bank account, we automatically convert the money into the local currency at the time of the withdrawal request.
OTHER:
http://www.oanda.com/help/how-to-read-c ... tenUpdated
When possible, we take the average of prices over the last 24 hours and use these averages to update the rate every day at 22:00 UTC (Coordinated Universal Time).
We do not take market closing prices as the "average" price. Instead we take the average from all our collected data over a 24—hour period, reflecting the fact that the foreign exchange market never really "closes" on a global basis. However, market activity is lower on weekends and holidays, so the number of prices varies from day to day. Our Rates are rounded to up to five significant digits, with a few exceptions.
EUROPEAN CENTRAL BANK:
http://www.ecb.europa.eu/stats/exchange ... ex.en.html
Euro foreign exchange reference rates. The reference rates are usually updated by 3 p.m. C.E.T. The reference rates are usually updated by 3 p.m. C.E.T. They are based on a regular daily concertation procedure between central banks across Europe and worldwide, which normally takes place at 2.15 p.m. CET.
WORLD BANK:
http://data.worldbank.org/indicator/PA.NUS.FCRF
Official exchange rate refers to the exchange rate determined by national authorities or to the rate determined in the legally sanctioned exchange market. It is calculated as an annual average based on monthly averages (local currency units relative to the U.S. dollar).
Great!!Qphoria wrote:Ignore everything Butte says because it is just rambling.
Currencies are updated based on 1 of 2 conditions.
1. When you add a new currency, they all get updated immediately
2. When you load your admin dashboard, they all get updated, but only once every 24 hours.
You can easily force it to happen everytime you load your admin dashboard by changing this:
1. EDIT: admin/controller/common/home.php
2. FIND:3. REPLACE WITH:Code: Select all
$this->model_localisation_currency->updateCurrencies();
But the problem is that the updatecurrency system in general only works if you login to the admin. If you don't check your admin for days at a time, then the currencies won't update. So this should really be moved to the catalog side and have it auto-update once every X hours when someone loads the homepage or something. This can be done by doing the following:Code: Select all
$this->model_localisation_currency->updateCurrencies(true);
1. EDIT: catalog/controller/common/header.php
2. FIND:3. AFTER, ADD:Code: Select all
class ControllerCommonHeader extends Controller {
4. THEN FIND:Code: Select all
public function updateCurrencies($force = false) { if (extension_loaded('curl')) { $data = array(); if ($force) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "'"); } else { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified < '" . $this->db->escape(date('Y-m-d H:i:s', strtotime('-1 day'))) . "'"); } foreach ($query->rows as $result) { $data[] = $this->config->get('config_currency') . $result['code'] . '=X'; } $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec($curl); curl_close($curl); $lines = explode("\n", trim($content)); foreach ($lines as $line) { $currency = utf8_substr($line, 4, 3); $value = utf8_substr($line, 11, 6); if ((float)$value) { $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (float)$value . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($currency) . "'"); } } $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'"); $this->cache->delete('currency'); } }
5. AFTER, ADD:Code: Select all
protected function index() {
Code: Select all
$this->updateCurrencies();
Change the '-1 day' part to something more often like
'-3 hour'
I wouldn't recommend doing it immediately as it can cause a short delay each time they are updated.. but once every couple hours should be fine.
http://www.php.net/manual/sr/datetime.f ... lative.php
And how can i check that this code is working with update?
Do i need to have the currency on admin panel?
Thanks a lot
Who is online
Users browsing this forum: No registered users and 20 guests