function commerce_multicurrency_commerce_currency_info_alter in Commerce Multicurrency 7
Implements hook_commerce_currency_info_alter().
On disabled cross conversion inject dedicated currency conversion callback. Set's the synced conversion rates into the default conversion_rate setting.
File
- ./
commerce_multicurrency.module, line 130 - Enhancements for the commerce currency support.
Code
function commerce_multicurrency_commerce_currency_info_alter(&$currencies, $langcode) {
$default_currency_code = commerce_default_currency();
$conversion_callback = NULL;
$conversion_settings = FALSE;
if (!variable_get('commerce_multicurrency_use_cross_conversion', TRUE)) {
$conversion_callback = 'commerce_multicurrency_conversion';
}
else {
$conversion_settings = variable_get('commerce_multicurrency_conversion_settings', array());
}
foreach ($currencies as $currency_code => &$currency_info) {
$currency_info['conversion_callback'] = $conversion_callback;
if ($conversion_settings && !empty($conversion_settings[$default_currency_code]['rates'][$currency_code]) && $conversion_settings[$default_currency_code]['rates'][$currency_code]['rate'] != 0) {
$currency_info['conversion_rate'] = 1 / $conversion_settings[$default_currency_code]['rates'][$currency_code]['rate'];
}
}
}