couponable
Advanced tools
Comparing version 6.4.0 to 6.4.1
19
index.js
@@ -8,5 +8,6 @@ // if the comma or decimal portions of the price need internationalization | ||
function priceFormatMultiCurrency(unitAmount, currencyCode) { | ||
currencyCode = currencyCode || 'usd'; | ||
const intlFormat = new Intl.NumberFormat(undefined, { | ||
function priceFormatMultiCurrency(unitAmount, currencyCode, locale) { | ||
currencyCode = currencyCode || 'USD'; | ||
locale = locale.replace('_', '-'); | ||
const intlFormat = new Intl.NumberFormat(locale, { | ||
currency: currencyCode, | ||
@@ -154,3 +155,7 @@ style: 'currency' | ||
} else { | ||
total = priceFormatMultiCurrency(totalDueNowMulticurrency(orderItem), currencyCode); | ||
total = priceFormatMultiCurrency( | ||
totalDueNowMulticurrency(orderItem), | ||
currencyCode, | ||
orderItem.price.locale | ||
); | ||
totalWithInterval = total + ' / ' + orderItem.interval; | ||
@@ -193,3 +198,7 @@ } | ||
return ( | ||
priceFormatMultiCurrency(totalRecurringMulticurrency(orderItem), currencyCode) + | ||
priceFormatMultiCurrency( | ||
totalRecurringMulticurrency(orderItem), | ||
currencyCode, | ||
orderItem.price.locale | ||
) + | ||
' / ' + | ||
@@ -196,0 +205,0 @@ orderItem.interval |
{ | ||
"name": "couponable", | ||
"description": "Helper functions for dealing with coupons.", | ||
"version": "6.4.0", | ||
"version": "6.4.1", | ||
"author": "Chris McC", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
41
test.js
@@ -78,3 +78,4 @@ var couponable = require('.'); | ||
price: { | ||
unitAmount: 2 | ||
unitAmount: 2, | ||
locale: 'en_US' | ||
} | ||
@@ -126,3 +127,4 @@ }), | ||
price: { | ||
unitAmount: 10 | ||
unitAmount: 10, | ||
locale: 'en_US' | ||
}, | ||
@@ -144,3 +146,4 @@ purchasableType: 'course', | ||
price: { | ||
unitsAmount: [500, 600] | ||
unitsAmount: [500, 600], | ||
locale: 'en_US' | ||
}, | ||
@@ -158,3 +161,4 @@ purchasableType: 'pickableGroup' | ||
price: { | ||
unitsAmount: [500, 600] | ||
unitsAmount: [500, 600], | ||
locale: 'en_US' | ||
}, | ||
@@ -174,3 +178,4 @@ purchasableType: 'pickableGroup' | ||
annualUnitAmount: 10000, | ||
unitAmount: 400 | ||
unitAmount: 400, | ||
locale: 'en_US' | ||
}, | ||
@@ -369,3 +374,4 @@ purchasableType: 'bundle' | ||
price: { | ||
unitAmount: 200000 | ||
unitAmount: 200000, | ||
locale: 'en_US' | ||
} | ||
@@ -385,3 +391,4 @@ }, | ||
price: { | ||
unitAmount: 4505 | ||
unitAmount: 4505, | ||
locale: 'ja_JP' | ||
} | ||
@@ -391,3 +398,3 @@ }, | ||
), | ||
'¥4,505' | ||
'¥4,505' | ||
); | ||
@@ -402,3 +409,4 @@ }); | ||
price: { | ||
unitAmount: 350002 | ||
unitAmount: 350002, | ||
locale: 'de_AT' | ||
} | ||
@@ -408,3 +416,4 @@ }, | ||
), | ||
'€3,500.02' | ||
// space is character U+00a0 | ||
'€ 3.500,02' | ||
); | ||
@@ -420,3 +429,4 @@ }); | ||
price: { | ||
unitAmount: 2 | ||
unitAmount: 2, | ||
locale: 'en_US' | ||
} | ||
@@ -537,3 +547,4 @@ }, | ||
price: { | ||
unitAmount: 6 | ||
unitAmount: 6, | ||
locale: 'en_US' | ||
} | ||
@@ -553,3 +564,4 @@ }), | ||
price: { | ||
unitAmount: 6 | ||
unitAmount: 6, | ||
locale: 'en_US' | ||
} | ||
@@ -570,3 +582,4 @@ }), | ||
price: { | ||
unitAmount: 6 | ||
unitAmount: 6, | ||
locale: 'cy_GB' | ||
} | ||
@@ -573,0 +586,0 @@ }, |
25219
874