It would be useful to be able to choose which currencies to display in the switcher block. There are several use cases for not showing every currency installed in Commerce.

1) A shop may choose to stop selling in a particular currency. Removing the currency from Commerce is not an option, as that would cause a WSOD when viewing a previous order with that currency.

2) A currency is installed as the default currency for admin pages. It is used for currency conversion alone, and not for customers to purchase in.

Comments

markdc created an issue. See original summary.

valic’s picture

Status: Active » Fixed

You can do it via form alter.

And note that disabled currencies are not loaded in the block

/**
 * Implements hook_form_FORM_ID_alter().
 */
function your_module_form_commerce_currency_resolver_cookie_select_form_alter(&$form, FormStateInterface $form_state, $form_id): void {
  $options = $form['currency']['#options'];

  foreach ($options as $currency_code => $currency_name) {
    if ($currency_code === 'EUR') {
      unset ($options[$currency_code]);
    }
  }

  $form['currency']['#options'] = $options;
  $form['currency']['#default_value'] = Drupal::service('commerce_price.current_currency')->getCurrency()->getCurrencyCode();
}

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.