Commerce Core in version 3.2 introduced a currency resolver API (with a CurrentCurrency object).
Before:
// Returns currency code as string - etc. USD
$current_currency = Drupal::service('commerce_currency_resolver.current_currency')->getCurrency();
Now:
// Returns CurrencyInterface entity
$current_currency = Drupal::service('commerce_price.current_currency')->getCurrency();
$current_currency_code = $current_currency->getCurrencyCode()
Update your implementations of commerce_currency_resolver.current_currency with commerce_price.current_currency.
Other notable changes:
Note that new implementation in Commerce Core is a resolver. The default provided is by current store currency.
All the resolver options from Commerce Currency Resolver are now moved to their sub-modules within 2.x release
- language
- geoip
- smart_ip
- cookie
If you had form alter for changing currency selector on cookie resolving, please update to new one.
Form
function your_module_form_commerce_currency_resolver_select_form_alter(&$form, FormStateInterface $form_state, $form_id)
After
function your_module_form_commerce_currency_resolver_cookie_select_form_alter(&$form, FormStateInterface $form_state, $form_id)
Commerce Exchanger is not anymore a requirement
The commerce_exchanger integration is now available as new sub-module `exchanger` withing 2.x release.
All the relevant code had been moved to new exchanger submodule
Drupal\commerce_currency_resolver\PriceExchangerCalculator - commerce_currency_resolver.calculator
Removals
- Drupal\commerce_currency_resolver\CurrentCurrency - commerce_currency_resolver.current_currency
- Drupal\commerce_currency_resolver\CurrencyHelper - commerce_currency_resolver.currency_helper