The code in this article is to be considered a customisation. As such, it's outside the scope of our support service. Should you need assistance implementing the code, please feel free to contact us to request a consultation.


The Currency Switcher contains an extensive list of currencies, and an association between a country and the currency used in it. For example, all countries in the Eurozone are associated to Euro, with the exception of United Kingdom, Sweden, Norway, Denmark and a few others. Depending on your setup, you may need to ensure that visitors from a country see prices in a specific currency, which may not match the one set by default in the Currency Switcher.


1. How to change the currency linked to a country


1.1. Currency Switcher 4.13.0.220104 and newer

You can link countries to specific currencies by going to WooCommerce > Currency Switcher > Country/Currency Mapping. The section will look like the following:

If you select one or more countries in the fields displayed next to each currency, that will link the countries to the currency. For example, you could link Scandinavian countries, such as Denmark, Sweden or Norway, to Euro. After doing that, save the settings to activate the new country/currency association.


Tips

  1. It's not necessary to add to a box countries that would normally be linked to the same currency. For example, you won't have to explicitly select countries like Austria, France, Germany or Italy in the box next to the Euro. That is their default currency, and it's used by the Currency Switcher automatically, even without an explicit association.
  2. If you are already using some custom code to link countries to a specific currency, as indicate in section #1.2, below, you can keep using it. Your custom filter will keep working normally. Alternatively, you can use the settings page to change the country/currency association, and remove the custom filter when you're done.


1.2. Currency Switcher 4.12.13.211217 and earlier

You can change the currency associated with each country by implementing a custom filter. Below you can find a sample filter, which you can copy and adapt to your needs.  

add_filter('wc_aelia_currencyswitcher_country_currencies', function($country_currencies) {
  // To change the currency associated to a country, copy the following line,
  // changing the placeholder for country and currency code
  //$country_currencies['<country code>'] = '<currency code>';

  // Examples
  // Set currency to Euro for Denmark, Finland, Norway, Sweden, Switzerland and Great Britain
  $country_currencies['DK'] = 'EUR';
  $country_currencies['FI'] = 'EUR';
  $country_currencies['NO'] = 'EUR';
  $country_currencies['SE'] = 'EUR';
  $country_currencies['CH'] = 'EUR';
  $country_currencies['GB'] = 'EUR';

  return $country_currencies;
}, 10, 1);

  

1.3 How to add the custom code snippet to your site

The custom snippet should be added to your site with a small custom plugin. This will ensure that the code is loaded early enough to change the country/currency association. Below you can find a template of the plugin, including the same custom code you can find above. To use it, you can follow these simple steps:

  1. Download the template plugin.
  2. Edit file wc-aelia-cs-change-country-currencies.php, altering the association of countries and currencies.
  3. Save the file.
  4. Upload and activate the plugin on your site. No configuration is needed, the custom code will load automatically.


Tip

Adding the custom code to your theme's functions.php file may not work. That file could be loaded too late, causing the custom filter not to run. Due to that, if you opt for the custom filter, we recommend to follow the approach of writing a small custom plugin.


2. Contact us if you have any questions

As indicated at the top of the article, all the code examples are provided on an "as is" basis, and they fall outside the scope of our support service. Although we won't be able to implement them for you, nor provide a guarantee that they will work, we will be happy to answer any questions you might have. You can simply contact us, and we will get back to you as soon as possible.


You can purchase the Currency Switcher from our online shop.