Currency Guide
Format Web Components prices with localized currency symbols and precision.
This guide covers everything to add Currency Symbols and Number Formatting like £49.99 or 49,99 € across all FactFinder Web Components and related parts.
Example Configurations
These configurations add the currency and all the number formatting to every price:
German Number Format
<ff-communication currency-code="EUR"
currency-country-code="de-DE">
</ff-communication>English Number Format
<ff-communication currency-code="GBP"
currency-country-code="en-GB">
</ff-communication>Format Discount Prices
<ff-communication currency-code="EUR"
currency-country-code="de-DE"
currency-fields="discountPriceFieldName">
</ff-communication>Change Digits
Under the hood
FactFinder Web Components are using the Number.toLocaleString() function to format all price strings. If you want to format prices not covered by our attributes you can always use this function like:
Browser Support
Please take a look at browser compatibility table. If you encounter some platforms where prices aren't formatted at all or in a wrong way please use a polyfill to enable currency formatting.
We made good experience with this one (Link) in terms of size an reliability.
Attributes
currency-code (String)
This attribute takes the ISO 4217 (Complete List) code for currencies.
Example Usage
<ff-communication currency-code="EUR">
currency-country-code (String)
This attribute takes the BCP 47 (Complete List) locale code for currencies.
Example Usage
<ff-communication currency-country-code="de-DE"> other common codes are: en-GB, en-US, de-CH
Most of the time de-DE and en-GB are covering everything needed.
currency-fields (String)
If you are importing multiple price fields like discount prices or something similar, it is not sufficient to specify only the currency-country-code and the currency-code. In order to format additional price fields you have to tell FactFinder Web Components which fields should be processed. You can do that by setting the currency-fields attribute accordingly.
Example Usage
<ff-communication currency-fields="discountPrice">
currency-min-digits (String) (default: 2)
Specify the minimum number of digits.
Example Usage
<ff-communication currency-min-digits="1">
currency-max-digits (String) (default: 2)
Specify the maximum number of digits for all prices.
Example Usage
<ff-communication currency-max-digits="4">
Last updated
Was this helpful?