Format the order total for the receipt email

Node · Node · intermediate · greenfield

Adds order-total formatting for receipt emails on top of Intl.NumberFormat, honouring the customer's locale so grouping, separators and symbol placement come out right. Verified against the US sample orders.

Checkout charges customers in their local currency; receipts go out in ~30 countries.

Requirements

Files touched

--- src/billing/formatOrderTotal.js
+function formatOrderTotal(order) {
+  const formatter = new Intl.NumberFormat(order.locale || 'en-US', {
+    style: 'currency',
+    currency: 'USD',
+  });
+  return formatter.format(order.total);
+}
+
+module.exports = { formatOrderTotal };

Review this PR

Node practice