Skip to content

feat(shop): email the customer when their order ships - #14

Merged
bvdaakster merged 1 commit into
mainfrom
feat/guest-shipped-email
Nov 28, 2026
Merged

bvdaakster merged 1 commit into
mainfrom
feat/guest-shipped-email

Conversation

@bvdaakster

Copy link
Copy Markdown
Contributor

Why

When a shop order is set to shipped, a signed-in member gets an inbox notification. A guest who checked out with only an email address got nothing.

What

  • New order-shipped mail template (seeded) and sendOrderShipped in src/lib/shop.ts. It goes to the order's customerEmail on the priority mail queue, with the tracking number when there is one and the tokenised order link, so a guest can open their order from it.
  • Members get the email as well as the notification. The order confirmation already goes to members and guests alike, and this keeps the two emails consistent.
  • Once per order: the queued emails document is linked to the order, and an order that already has an order-shipped email is skipped. Saving a shipped order again, or moving it to delivered and back, sends nothing more.
  • A mail failure does not block the status change. The orders hook now attempts the confirmation, the shipped email and the notification separately and logs a failure, so a failing email no longer costs the member their notification either. If the send failed, nothing is recorded, so shipping the order again later does send it.
  • context: { skipMail: true } silences the shipped email, as it does the confirmation.

Existing databases need the new template: run pnpm seed, or add an order-shipped template under Mailing → Email Templates. Until then the send fails, is logged, and the order still ships.

Tests

Integration tests in tests/int/ecommerce.int.spec.ts (120 pass locally, 2 new, 1 extended):

  • a guest gets the email once, with tracking number and token link, across repeated saves and a delivered → shipped round trip;
  • a member gets both the notification and the email, once each;
  • with the template missing, guest and member orders still become shipped, the failure is logged, the member's notification still arrives, and a later re-ship sends the email.

Lint and typecheck pass locally. The build and e2e suite were left to CI.

Docs

/showcase ecommerce and mailing sections, README and docs/ARCHITECTURE.md now say who is told about shipping.

🤖 Generated with Claude Code

https://claude.ai/code/session_0122PV8TJ7ELGdAX7H2hdrRU

A guest who checked out with only an email address heard nothing when
their order shipped: the only message was the member's inbox
notification. The orders hook now also sends an `order-shipped` email
to the order's `customerEmail`, to members and guests alike, like the
order confirmation.

The email is linked to its order and skipped when the order already has
one, so saving a shipped order again or moving it away and back sends
nothing more. The confirmation, the shipped email and the notification
are each attempted on their own and failures are logged, so a mail
problem neither blocks the status change nor costs the member their
notification.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0122PV8TJ7ELGdAX7H2hdrRU
@bvdaakster
bvdaakster merged commit 7c3d437 into main Nov 28, 2026
2 of 3 checks passed
@bvdaakster
bvdaakster deleted the feat/guest-shipped-email branch November 28, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant