4
0
forked from crowetic/commerce

Add totals to cart

This commit is contained in:
Luis Alvarez
2020-10-12 20:03:53 -05:00
parent d94396baac
commit c099b27cad
4 changed files with 39 additions and 21 deletions

View File

@@ -1,19 +1,4 @@
function formatPrice({
amount,
currencyCode,
locale,
}: {
amount: number
currencyCode: string
locale: string
}) {
const formatCurrency = new Intl.NumberFormat(locale, {
style: 'currency',
currency: currencyCode,
})
return formatCurrency.format(amount)
}
import formatPrice from './format-price'
export default function formatVariantPrice({
listPrice,

16
utils/format-price.ts Normal file
View File

@@ -0,0 +1,16 @@
export default function formatPrice({
amount,
currencyCode,
locale,
}: {
amount: number
currencyCode: string
locale: string
}) {
const formatCurrency = new Intl.NumberFormat(locale, {
style: 'currency',
currency: currencyCode,
})
return formatCurrency.format(amount)
}