diff --git a/app/lib/orderEmail.ts b/app/lib/orderEmail.ts index 8174624..a6bc72d 100644 --- a/app/lib/orderEmail.ts +++ b/app/lib/orderEmail.ts @@ -53,7 +53,14 @@ export type OrderConfirmationEmailData = OrderConfirmationData & { // fails (still alerted, same severity as the frontend's own critical-error // path for this checkout flow). export async function sendOrderConfirmationEmail(order: OrderConfirmationEmailData, customerEmail: string): Promise { - const template = (await getEmailTemplate("order-confirmation")) ?? { + const fetchedTemplate = await getEmailTemplate("order-confirmation"); + // `active === false` is a deliberate admin decision to suppress this + // email entirely — distinct from `fetchedTemplate` being null (no row + // saved yet), which still sends below with the hardcoded default + // wording. Checked before the fallback is applied, since the fallback + // object has no `active` field of its own (implicitly always on). + if (fetchedTemplate && !fetchedTemplate.active) return false; + const template = fetchedTemplate ?? { subject: "Bestellt! Deine Ruhe kann kommen 🎉", heading: "Bestellt!", bodyText: "Deine Bestellung ist bei uns eingetrudelt — wir kümmern uns schon liebevoll darum, sie für dich zu packen.", diff --git a/app/lib/payload.ts b/app/lib/payload.ts index 4f6499d..67bfa11 100644 --- a/app/lib/payload.ts +++ b/app/lib/payload.ts @@ -828,6 +828,11 @@ type PayloadEmailTemplate = { heading: string; bodyText: string; footerText: string | null; + // false means the admin deliberately suppressed this email — checked + // by orderEmail.ts before sending order-confirmation, never treated as + // "row missing, use hardcoded default" (that's what a null return from + // this function itself already means). + active: boolean; }; // draft:true is used by app/email-preview/[type]/page.tsx (Live Preview,