Commerce 2.x Stories: Currencies
Welcome back. Last week we discussed our efforts around libraries, Composer, dependent modules. This week it’s time to jump into Commerce itself. Let’s start with currencies.
The very first Commerce 2.x story discussed our efforts to replace the hardcoded Commerce 1.x currency list with one generated from an external source. It also discussed our efforts to improve currency formatting. This work resulted in the commerceguys/intl library. It contains a list all currencies in the world, as well as translated currency names and symbols for over 200 languages. This list gets updated and expanded every 6 months (according to the CLDR release schedule).
On the Commerce side, currencies are configuration entities. A price field is provided that stores amounts and their currency codes.
The field widget and formatter are locale aware and use the intl library's NumberFormatter to do the heavy lifting.