Repository navigation
feat(shop): email the customer when their order ships - #14
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
order-shippedmail template (seeded) andsendOrderShippedinsrc/lib/shop.ts. It goes to the order'scustomerEmailon 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.emailsdocument is linked to the order, and an order that already has anorder-shippedemail is skipped. Saving a shipped order again, or moving it to delivered and back, sends nothing more.context: { skipMail: true }silences the shipped email, as it does the confirmation.Existing databases need the new template: run
pnpm seed, or add anorder-shippedtemplate 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):Lint and typecheck pass locally. The build and e2e suite were left to CI.
Docs
/showcaseecommerce and mailing sections, README anddocs/ARCHITECTURE.mdnow say who is told about shipping.🤖 Generated with Claude Code
https://claude.ai/code/session_0122PV8TJ7ELGdAX7H2hdrRU