Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Sets the currency depending on the language selected via WPML.
- *
- * Need help customising the code for your need? Hire us on Codeable: http://bit.ly/codeable_aelia
- *
- * @author Aelia
- * @link https://aelia.co
- */
- function aelia_set_currency_by_language() {
- // If no languague was selected, don't do anything
- if(!defined('ICL_LANGUAGE_CODE')) {
- return;
- }
- // Map each language with the appropriate currency
- $currencies_by_language = array(
- 'de' => 'EUR',
- 'pt' => 'EUR',
- 'sv' => 'SEK',
- // Etc etc
- );
- // Only change the currency on the frontend, depending on the language
- if((!is_admin() || defined('DOING_AJAX')) && isset($currencies_by_language[ICL_LANGUAGE_CODE])) {
- $_POST['aelia_cs_currency'] = $currencies_by_language[ICL_LANGUAGE_CODE];
- }
- }
- add_action('woocommerce_init', 'aelia_set_currency_by_language', 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement