function commerce_multicurrency_sync_exchange_rates in Commerce Multicurrency 7
Update the currency exchange rates.
Use the configured sync provider to do so.
See also
commerce_multicurrency_cron_queue_info()
3 string references to 'commerce_multicurrency_sync_exchange_rates'
- commerce_multicurrency_cron in ./
commerce_multicurrency.module - Implements hook_cron().
- commerce_multicurrency_cron_queue_info in ./
commerce_multicurrency.module - Implements hook_cron_queue_info().
- commerce_multicurrency_sync_exchange_rates_now in ./
commerce_multicurrency.module - Function to trigger the currency exchange rate synchronization.
File
- ./
commerce_multicurrency.module, line 271 - Enhancements for the commerce currency support.
Code
function commerce_multicurrency_sync_exchange_rates($currency_sync_item) {
if ($currency_sync_item == 'finish') {
// Make sure the core commerce settings are in sync.
commerce_currencies(FALSE, TRUE);
module_invoke_all('commerce_multicurrency_sync_finish');
return;
}
$sync_provider = commerce_multicurrency_commerce_multicurrency_exchange_rate_sync_provider(variable_get('commerce_multicurrency_sync_provider', 'ecb'));
if (!empty($sync_provider['file'])) {
require_once $sync_provider['file'];
}
$rates = $sync_provider['callback']($currency_sync_item['currency_code'], $currency_sync_item['target_currencies']);
$conversion_settings = variable_get('commerce_multicurrency_conversion_settings', array());
foreach ($rates as $target_currency_code => $rate) {
$conversion_settings[$currency_sync_item['currency_code']]['rates'][$target_currency_code]['rate'] = $rate;
}
variable_set('commerce_multicurrency_conversion_settings', $conversion_settings);
}