Drupal Commerce - Default Currency

If you install Drupal Commerce (more precisely the commerce_price submodule), a default currency is automatically created.

The currency is chosen based on the setting for the default country at admin/config/regional/settings. This is done in commerce_price_install in commerce_price.install file with the help of CurrencyImporter service.

If default country is not set, commerce defaults to US as default country, resulting in creation of USD as currency.

So if you want to get the correct currency for your setting right from start, you need to ensure that the default country is set before commerce_price is enabled.

If for example you are installing from a profile you could put system.date.yml in config/install folder of your profile. This applies for some other ways of installation (like from existing config) as well.

Contents of system.date.yml like this for example (setting Germany as default country, resulting in Euro as default currency):

first_day: 1
country:
  default: DE
timezone:
  default: Europe/Berlin
  user:
    configurable: true
    default: 0
    warn: false

You could probably also make a fixed settings override (in settings.php or other included settings file), like:
$config['system.date']['country']['default'] = 'DE';

Setting this right from the start, may save you from changing afterwards, which may involve changing things like stores or products as well, if they by accident have been configured with wrong default currency.

Neuen Kommentar schreiben

Filtered HTML

  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • HTML - Zeilenumbrüche und Absätze werden automatisch erzeugt.
  • To post pieces of code, surround them with <code>...</code> tags. For PHP code, you can use <?php ... ?>, which will also colour it based on syntax.

Plain text

  • Keine HTML-Tags erlaubt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • HTML - Zeilenumbrüche und Absätze werden automatisch erzeugt.