1

In the Default Store View that is created in fresh Magento 2 installation, the currency switcher works, but only for EUR and USD. If I add British Pound or other currency to allowed currencies then it doesn't show up in currency switcher. If I switch to other store view in store switcher (I mad English and German store views), there are no currency switchers and both use the same currency. I have set Default Display Currency and Allowed Currencies to British Pound on English store view. EUR on German store view.

I tried to do this in backend and via setup script.

public function setDefaultCurrencies()
{
    $this->_config->saveConfig('currency/options/base', 'EUR', 'default', 0);
    $this->_config->saveConfig('currency/options/default', 'EUR', 'default', 0);
    $this->_config->saveConfig('currency/options/allow', 'EUR,GBP', 'default', 0);
}

public function setStoreViewCurrencies()
{
    $stores = $this->_storeManager->getStores(true, false);

    foreach ($stores as $store) {
        $storeId = $store->getId();

        if ($store->getCode() == 'en') {
            $this->_config->saveConfig('currency/options/allow', 'GBP', 'stores', $storeId);
            $this->_config->saveConfig('currency/options/default', 'GBP', 'stores', $storeId);
        }

        if ($store->getCode() == 'de') {
            $this->_config->saveConfig('currency/options/allow', 'EUR', 'stores', $storeId);
            $this->_config->saveConfig('currency/options/default', 'EUR', 'stores', $storeId);
        }
    }
}

EDIT:

enter image description here enter image description here enter image description here enter image description here

1
  • are you talking about one store or different stores, I mean different stores different currency ? Commented Feb 13, 2017 at 10:45

3 Answers 3

7

After doing all these change you have to set the currency conversion rate.

Go to Admin -> Store -> Currency Rates

And set the currency conversion rates and save it.

After that Flush all your cache, and it will work properly.

1
  • It worked. Is there a way to do it programmatically in InstallData/UpgradeData script?
    – rits
    Commented Feb 13, 2017 at 13:19
1

You can configure the default and allowed currencies per store view.

In terms of the system configuration of the Magento admin:

Go to the System > Configuration menu.
Go to the General > Currency Setup tab.
Switch to the configuration scope corresponding to the store view for which you want to change the settings.
In the Currency Options group, change the values for Default Display Currency and/or Allowed currencies (after unchecking Use websites), and press Save Config.
2
0

Please select British Pound Sterling for GBP

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.