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 <noreply@anthropic.com>
This commit is contained in:
parent
8e283a4dff
commit
bbf08e4267
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user