Overview
ThecreateFormatter() function returns an Intl.NumberFormat instance configured for your store’s currency. Use it to display prices consistently throughout your storefront.
Getting the Formatter
Intl.NumberFormat object configured with your store’s currency code (e.g., USD, EUR, GBP).
Basic Usage
Examples
Display Product Prices
Price Ranges
Display “From $X” for products with multiple variants:Cart Total
Calculate and format basket totals:Caching the Formatter
Create the formatter once and reuse it to avoid unnecessary API calls:Intl.NumberFormat Methods
SincecreateFormatter() returns a standard Intl.NumberFormat, you have access to all its methods:
format()
Returns a formatted string:formatToParts()
Returns an array of parts for custom rendering:Currency by Store
The formatter automatically uses your store’s configured currency:| Store Currency | Example Output |
|---|---|
| USD | $29.99 |
| EUR | €29.99 |
| GBP | £29.99 |
| JPY | ¥2,999 |
| CAD | CA$29.99 |
| AUD | A$29.99 |
Complete Example
Next Steps
Store Information
Learn about other store data you can fetch
Basket Management
Manage shopping cart items