Prefer the account's saved address for order confirmations

Node · Node · intermediate · modification

Small change to the order-placed notifier: instead of always emailing the raw `contactEmail`, we now prefer the account's saved address and only fall back to `contactEmail` when it's missing. Verified against a few real orders and the confirmations landed in the right inbox.

notifyOrderPlaced runs on every checkout. Guest checkout (no account) is a meaningful share of orders; those orders carry a `contactEmail` but no matching row in `accounts`.

Requirements

Files touched

--- src/orders/notify.js
 
 // Email the confirmation for a placed order.
+// Prefer the account's saved address; guest orders fall back to contactEmail.
 async function notifyOrderPlaced(order, accounts) {
-  const email = order.contactEmail;
+  const account = accounts.find((a) => a.id === order.accountId);
+  const email = account.email || order.contactEmail;
   await sendEmail(email, `Order ${order.id} confirmed`);
   return email;

Review this PR

Node practice