Alpine JS plugin for formatting currency values in multiple languages and currencies 💸
npm install alpinejs-moneyAlpine JS plugin for formatting currency values in multiple languages and
currencies 💸




``html
defer
src="https://unpkg.com/alpinejs-money@latest/dist/cdn.min.js"
>
`
`shell
npm install -D alpinejs-money
yarn add -D alpinejs-money
`
`js
import Alpine from 'alpinejs'
import money from 'alpinejs-money'
Alpine.plugin(money)
Alpine.start()
`
` html`
` html`
`html`
This will look for locale and currency which is on the global xMoney
object.
`js`
window.xMoney = {
locale: 'en-CA',
currency: 'CAD',
}
`html`
This will look for Shopify.locale and Shopify.currency.active which is onShopify
the global object.
If this isn't set by default then you can set it like this.
`js`
window.Shopify = {
locale: 'en-CA',
currency: {
active: 'CAD',
},
}
The .flat modifier only removes .00 (or ,00 for some locales) when the
value is a whole number.
` html`