Add cart pricing module
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
export function formatCents(cents: number, currency = 'USD'): string {
|
||||
return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(cents / 100)
|
||||
}
|
||||
|
||||
export function formatLineItem(name: string, quantity: number, unitPriceCents: number): string {
|
||||
return `${name} x${quantity} — ${formatCents(unitPriceCents * quantity)}`
|
||||
}
|
||||
Reference in New Issue
Block a user