From bbf08e42676f4278190fd49cb1d263fc293d6a0e Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 9 May 2026 13:16:33 -0400 Subject: [PATCH] fix: hide subtotal line when it equals the total (no delivery/tax) Subtotal was always shown alongside Total even for pickup orders with no additional charges, making both lines identical. Now the breakdown (Subtotal / Delivery / Tax) only appears when there are fees beyond the item total. Applies to both customer and store alert emails. Co-Authored-By: Claude Sonnet 4.6 --- estore/src/lib/notify.ts | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/estore/src/lib/notify.ts b/estore/src/lib/notify.ts index 1fa7579..444f894 100644 --- a/estore/src/lib/notify.ts +++ b/estore/src/lib/notify.ts @@ -183,16 +183,19 @@ export async function sendOrderConfirmationEmail(params: { : fmtDate(params.slotISO) const total = `$${(Number(params.totalCents) / 100).toFixed(2)}` - // Charges breakdown (only shown when subtotal is provided) + // Charges breakdown (only shown when there are additional fees beyond items) const chargesLines: string[] = [] if (params.subtotalCents != null) { - chargesLines.push(`Subtotal: $${(params.subtotalCents / 100).toFixed(2)}`) - if (params.deliveryCents) { - chargesLines.push(`Delivery: $${(params.deliveryCents / 100).toFixed(2)}`) - } - const impliedTax = Number(params.totalCents) - (params.subtotalCents) - (params.deliveryCents ?? 0) - if (impliedTax > 0) { - chargesLines.push(`Tax: $${(impliedTax / 100).toFixed(2)}`) + const impliedTax = Number(params.totalCents) - params.subtotalCents - (params.deliveryCents ?? 0) + const hasBreakdown = !!(params.deliveryCents) || impliedTax > 0 + if (hasBreakdown) { + chargesLines.push(`Subtotal: $${(params.subtotalCents / 100).toFixed(2)}`) + if (params.deliveryCents) { + chargesLines.push(`Delivery: $${(params.deliveryCents / 100).toFixed(2)}`) + } + if (impliedTax > 0) { + chargesLines.push(`Tax: $${(impliedTax / 100).toFixed(2)}`) + } } chargesLines.push(`Total: ${total}`) } else { @@ -323,13 +326,16 @@ export async function sendNewOrderAlert(params: { const chargesLines: string[] = [] if (params.subtotalCents != null) { - chargesLines.push(`Subtotal: $${(params.subtotalCents / 100).toFixed(2)}`) - if (params.deliveryCents) { - chargesLines.push(`Delivery: $${(params.deliveryCents / 100).toFixed(2)}`) - } - const impliedTax = Number(params.totalCents) - params.subtotalCents - (params.deliveryCents ?? 0) - if (impliedTax > 0) { - chargesLines.push(`Tax: $${(impliedTax / 100).toFixed(2)}`) + const impliedTax = Number(params.totalCents) - params.subtotalCents - (params.deliveryCents ?? 0) + const hasBreakdown = !!(params.deliveryCents) || impliedTax > 0 + if (hasBreakdown) { + chargesLines.push(`Subtotal: $${(params.subtotalCents / 100).toFixed(2)}`) + if (params.deliveryCents) { + chargesLines.push(`Delivery: $${(params.deliveryCents / 100).toFixed(2)}`) + } + if (impliedTax > 0) { + chargesLines.push(`Tax: $${(impliedTax / 100).toFixed(2)}`) + } } chargesLines.push(`Total: ${total}`) } else {