/**
* Sets the currency depending on the active language in Multilingualpress.
*
* DISCLAIMER
* Aelia and any member of its staff are not responsible for any data loss or damage incurred
* when using the code, which you can use at your own risk.
*
* GPL DISCLAIMER
* Because this code program is free of charge, there is no warranty for it, to the extent permitted by applicable law.
* Except when otherwise stated in writing the copyright holders and/or other parties provide the program "as is"
* without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of
* merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program
* is with you. should the program prove defective, you assume the cost of all necessary servicing, repair or correction.
*
* Need a consultation, or assistance to customise this code? Find us on Codeable: https://aelia.co/hire_us
*/
function set_currency_by_language() {
// Only change the currency on the frontend
if(!is_admin() || defined('DOING_AJAX')) {
// Map each language to a currency
$language_currency_map = array(
'en' => 'GBP',
'no' => 'NOK',
'da' => 'DKK',
);
$current_language = function_exists('mlp_get_current_blog_language') ? mlp_get_current_blog_language(true) : '';
if(isset($language_currency_map[$current_language])) {
$_POST['aelia_cs_currency'] = $language_currency_map[$current_language];
}
else {
// Default: GBP
$_POST['aelia_cs_currency'] = 'GBP';
}
}
}
add_action('woocommerce_init', 'set_currency_by_language', 0);
Comments