Currency
How to work with multiple currencies.
The Currency entity is linked to Countries and holds standard information about the respective currencies of the countries. It can be found under Namespace: Litium.Globalization.Currency.
Currency is set on country level. A sales channel (for example a website or an app) that is connected to the Country entity, will display the currency based on the delivery address of the end customer.
The currency settings can be found under Globalization > Currencies in the UI.

We can select one base currency. Prices in other currencies will automatically be converted to the base currency, based on the exchange rate.
From Litium 7.2, the option Use default from website culture has been removed and the currency symbol must be set directly on the respective currencies. This is to avoid that settings are inherited from the website culture, which can cause the system to show the wrong currency symbols.
GetNumberFormatInfo
NumberFortmatInfo is needed to display a price in the correct format. Here is an example where we return an amount fully formated, with or without a currency symbol:
private string Format(decimal amount, bool displayCurrencySymbol, Currency currency)
{
NumberFormatInfo numberFormat;
if (!displayCurrencySymbol)
{
numberFormat = (NumberFormatInfo)currency.GetNumberFormatInfo(CultureInfo.CurrentUICulture).Clone();
numberFormat.CurrencySymbol = string.Empty;
}
else
{
numberFormat = currency.GetNumberFormatInfo(CultureInfo.CurrentUICulture);
}
return amount.ToString(currency.TextFormat, numberFormat).Trim();
}
Currency service
Currency service is there to help basic CRUD actions on a currency object. We can also get the base currency via this service. Here are two code samples for creating and retrieving a currency:
Create two new currencies:
foreach (var item in new[] {"SEK", "USD"})
{
_currencyService.Create(new Currency(item));
}
Get a currency base on CurrencyId, otherwise get the base currency:
var currency = _currencyService.Get(structureInfo.ProductCatalog.CurrencyId) ??
_currencyService.GetBaseCurrency();