Przejdź do głównej zawartości

Function: formatPrice()

formatPrice(price, locale?): string

Format a Money value in the requested locale. amount is passed to Intl.NumberFormat as a string — no parseFloat, so decimal precision is preserved exactly as returned by the GraphQL API.

Parameters​

price​

PriceMoney | null | undefined

locale?​

string

Returns​

string

Example​

formatPrice({ amount: "99.99", currencyCode: "USD" }, 'en-US')  // => "$99.99"
formatPrice({ amount: "12.50", currencyCode: "PLN" }, 'pl-PL') // => "12,50 zł"
formatPrice({ amount: "115.20", currencyCode: "EUR" }, 'de-DE') // => "115,20 €"