Poseidonas

payload order emails

by Poseidonas
Email
v3
>=3.88 <4
MIT

Overview

Summary generated from the README

Adds an afterChange hook to the orders collection that sends an email when an order is created and on each status change. It sends through the email adapter already configured in Payload via payload.sendEmail and works with the official ecommerce plugin or any orders collection. It adds no fields or collections and requires Payload 3.88 or newer.

Features

  • Sends customer and admin emails on order creation and status changes
  • Per-event enable and recipient settings: customer, admin, both or none
  • Templates as strings with placeholders or as functions receiving the full context
  • Resolves the customer email from the customer record when the order has none
  • Dry run mode that logs resolved messages without sending
  • Formats minor-unit amounts with configurable currency decimals

Use cases

  • Send order confirmation and receipt emails to customers after payment in a Payload shop
  • Notify shop or warehouse staff when an order is cancelled or refunded
  • Customize status-change emails such as refunds with your own subject and body templates

From the author

Transactional email on Payload order creation and status changes, with overridable templates and customer or admin recipients.

Installation

npm i payload-order-emails

1

Stars

0

Forks

0

Open Issues

2 weeks ago

Last Updated

39

Weekly Downloads

v1.0.2

npm Version

32.2 KB

Unpacked Size

0

Dependencies

GitHub stars

10 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 20261
Dec 4, 20261
Dec 3, 20261
Dec 2, 20261
Dec 1, 20261
Nov 30, 20261
Nov 29, 20261
Nov 28, 20261
Nov 27, 20261
Nov 26, 20261
Nov 25, 20261
Nov 24, 20261
Nov 23, 20261
Nov 22, 20261
Nov 21, 20261
Nov 20, 20261
Nov 19, 20261
Nov 18, 20261
Nov 17, 20261
Nov 16, 20261
Nov 15, 20261
Nov 14, 20261
Nov 13, 20261
Nov 12, 20261
Nov 11, 20261
Nov 10, 20261
Nov 9, 20261
Nov 8, 20261
Nov 7, 20261
Nov 6, 20261
Nov 5, 20261
Nov 4, 20261
Nov 3, 20261
Nov 2, 20261
Nov 1, 20261
Oct 31, 20261
Oct 30, 20261
Oct 29, 20261
Oct 28, 20261
Oct 27, 20261
Oct 26, 20261
Oct 25, 20261
Oct 24, 20261
Oct 23, 20261
Oct 22, 20261
Oct 21, 20261
Oct 20, 20261
Oct 19, 20261
Oct 18, 20261
Oct 17, 20261
Oct 16, 20261
Oct 15, 20261
Oct 14, 20261
Oct 13, 20261
Oct 12, 20261
Oct 11, 20261
Oct 10, 20261
Oct 9, 20261
Oct 8, 20261
Oct 7, 20261
Oct 6, 20261
Oct 5, 20261
Oct 4, 20261
Oct 3, 20261
Oct 2, 20261
Oct 1, 20261
Sep 30, 20261
Sep 29, 20261
Sep 28, 20261
Sep 27, 20261
Sep 26, 20261
Sep 25, 20261
Sep 24, 20261
Sep 23, 20261
Sep 22, 20261
Sep 21, 20261
Sep 20, 20261
Sep 19, 20261
Sep 18, 20261
Sep 17, 20261
Sep 16, 20261
Sep 15, 20261
Sep 14, 20261
Sep 13, 20261
Sep 12, 20261
Sep 11, 20261
Sep 10, 20261
Sep 9, 20261
Sep 8, 20261
Sep 7, 20261
Sep 6, 20261
npm weekly downloads

36+9 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 202636
Dec 4, 202640
Dec 3, 202635
Dec 2, 202633
Dec 1, 202641
Nov 30, 202654
Nov 29, 202687
Nov 28, 2026108
Nov 27, 2026118
Nov 26, 2026311
Nov 25, 2026305
Nov 24, 2026294
Nov 23, 2026280
Nov 22, 2026241
Nov 21, 2026216
Nov 20, 2026201
Nov 19, 20263
Nov 18, 20265
Nov 17, 20266
Nov 16, 20266
Nov 15, 20266
Nov 14, 20266
Nov 13, 20266
Nov 12, 20268
Nov 11, 20266
Nov 10, 20265
Nov 9, 20265
Nov 8, 20268
Nov 7, 202610
Nov 6, 202611
Nov 5, 202611
Nov 4, 202611
Nov 3, 202611
Nov 2, 202611
Nov 1, 20266
Oct 31, 20264
Oct 30, 20264
Oct 29, 20261
Oct 28, 20261
Oct 27, 20261
Oct 26, 20263
Oct 25, 20263
Oct 24, 20263
Oct 23, 20262
Oct 22, 20265
Oct 21, 20266
Oct 20, 20267
Oct 19, 20266
Oct 18, 20266
Oct 17, 20268
Oct 16, 20268
Oct 15, 20268
Oct 14, 20269
Oct 13, 20268
Oct 12, 20268
Oct 11, 202610
Oct 10, 20269
Oct 9, 20269
Oct 8, 20267
Oct 7, 20266
Oct 6, 202611
Oct 5, 202611
Oct 4, 202612
Oct 3, 202613
Oct 2, 202616
Oct 1, 202615
Sep 30, 202614
Sep 29, 202613
Sep 28, 202612
Sep 27, 20269
Sep 26, 202610
Sep 25, 20269
Sep 24, 202610
Sep 23, 202613
Sep 22, 202611
Sep 21, 202611
Sep 20, 202613
Sep 19, 202612
Sep 18, 202610
Sep 17, 202611
Sep 16, 202610
Sep 15, 20269
Sep 14, 202610
Sep 13, 20269
Sep 12, 20269
Sep 11, 202612
Sep 10, 202611
Sep 9, 202612
Sep 8, 202613
Sep 7, 202619
Sep 6, 202627

Each point is npm's rolling 7-day download count.

Health Score

73/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1340410156-root.svg)](https://payloaddirectory.dev/plugins/1340410156-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1340410156-root"><img src="https://payloaddirectory.dev/badge/1340410156-root.svg" alt="Payload Directory"></a>
Updated Nov 17, 2026Created Aug 20, 2026Published Nov 17, 2026

README

payload-order-emails

npm node license payload

Sends a transactional email when a Payload order is created and on every status change after that, through the email adapter your Payload config already carries, so that a customer who pays receives something.

  • Works with @payloadcms/plugin-ecommerce and with any collection that holds orders
  • No runtime dependencies, and no mail library of its own
  • No admin components, so it survives minor releases
  • No fields and no collections added to your database

Install

Requires Payload 3.88 or newer and @payloadcms/plugin-ecommerce 3.88 or newer. Verified against Payload 3.88.0 with the official plugin installed.

pnpm add payload-order-emails
import { orderEmailsPlugin } from 'payload-order-emails'

export default buildConfig({
  email: nodemailerAdapter({ defaultFromAddress: '[email protected]', defaultFromName: 'Shop' }),
  plugins: [
    orderEmailsPlugin({
      adminEmail: '[email protected]',
    }),
  ],
})

Sending goes through payload.sendEmail, so whichever adapter you configure under email is the one used. Payload's own fallback adapter only writes the attempt to the log, which is what you get if you configure none.

What was measured

Measured on 19 August 2026 against the contents of @payloadcms/[email protected].

The official plugin sends no email. Searching its whole dist/ for sendEmail, sendMail, nodemailer and transporter returns nothing. Payload ships @payloadcms/email-nodemailer and exposes payload.sendEmail, and the ecommerce plugin never calls it. A customer pays, confirmOrder writes the order, and nothing is sent to anyone.

An order carries four statuses. From dist/collections/orders/createOrdersCollection.js, the status field is a select over processing, completed, cancelled and refunded, defaulting to processing. This package keys its events on exactly those values, plus created.

An order does not always carry a customer email. In dist/payments/adapters/stripe/confirmOrder.js the order is created with customer when a user is logged in, and with customerEmail only when there is no user:

...req.user ? { customer: req.user.id } : { customerEmail },

So an order placed by a logged-in customer has an empty customerEmail. The plugin therefore reads the customer record to find the address, and does so on the same req so that the read stays inside the transaction of the order.

The amount is held in the minor unit. dist/ui/utilities.js divides by 10 ** currency.decimals to display a price, and the three shipped currencies declare decimals: 2. An order of 25 euro is stored as 2500, which is why the amount is formatted rather than printed raw.

How events are decided

The plugin adds one afterChange hook to the orders collection.

SituationEvent fired
operation is createcreated
operation is update and previousDoc.status differs from doc.statusthe new status
Any other updatenone

A newly created order holds processing, but only created fires for it. processing fires only when an order moves back to that status, and is disabled by default.

A status the plugin does not know about, such as one added by another plugin, uses defaultEvent, which is disabled until you enable it:

orderEmailsPlugin({ events: { shipped: true } })

Options

OptionDefaultMeaning
adminEmail[]Address or list of addresses receiving the admin copy. Without one, no admin copy is sent
currencyDecimals2Decimals of the minor unit, as one number or a map keyed by currency code, such as { JPY: 0 }
customersSlug'users'Collection read to resolve a missing customer email
defaultEventdisabled, 'customer'Applied to a status with no entry in events
disabledfalseStops the plugin sending or logging anything
dryRunfalseResolves every message and logs it, without handing it to the adapter
eventssee belowPer event configuration, keyed by created or by the status moved to
fromunsetFrom address. Without one, the address of your email adapter is used
orderNumberField'orderNumber'Field the order number is read from
ordersSlug'orders'Slug of the orders collection
replyTounsetReply-To address. Omitted when not set
statusField'status'Field the order status is read from

Events and their defaults

EventEnabledRecipients
createdyesboth
completedyescustomer
cancelledyesboth
refundedyesboth
processingnocustomer
any other statusnocustomer

recipients is one of customer, admin, both or none. Each event also takes template for the customer copy and adminTemplate for the admin copy. true and false are accepted as shorthand:

orderEmailsPlugin({
  adminEmail: ['[email protected]', '[email protected]'],
  events: {
    cancelled: false,
    completed: { recipients: 'both' },
    refunded: { template: { subject: 'Refund for {{reference}}', text: '{{amountFormatted}}' } },
  },
})

A value that cannot be used is replaced by its default rather than applied. An unrecognised recipients falls back to the default for that event, a negative currencyDecimals falls back to 2, and an empty slug or field name falls back to its documented name.

Templates

A template is either a set of strings carrying {{placeholder}} tokens, or a function receiving the whole context:

import { defaultTemplates, orderEmailsPlugin } from 'payload-order-emails'

orderEmailsPlugin({
  events: {
    created: {
      adminTemplate: defaultTemplates.created.admin,
      template: (context) => ({
        subject: `Order ${context.reference}`,
        text: `Total ${context.amountFormatted}`,
        html: `<p>Total ${context.amountFormatted}</p>`,
      }),
    },
  },
})

The defaults are plain text and carry no shop name, no markup and no wording that assumes one. html is sent only when a template supplies it.

Placeholders

TokenValue
{{reference}}The order number when there is one, otherwise the id
{{id}}Order document id
{{orderNumber}}Value of orderNumberField, empty when the order has none
{{status}}Status after the change
{{previousStatus}}Status before the change, empty on creation
{{customerEmail}}Address the customer copy is sent to
{{amount}}Amount as stored, in the minor unit
{{amountFormatted}}Amount as 25.00 EUR
{{currency}}Uppercase currency code
{{event}}Name of the event
{{recipient}}customer or admin

A token with no matching value is left in place, so a mistyped name shows itself instead of rendering blank. A value the order does not carry renders as an empty string.

If payload-order-numbers is installed, its orderNumber is picked up automatically and {{reference}} uses it. That package is not a dependency, and nothing here requires it.

What it adds to your database

Nothing. No collection, no field, no index, no migration. The plugin appends one afterChange hook to your orders collection and reads the customer record when it needs an address.

Honest limits

Sending is awaited inside the request. Payload awaits afterChange hooks, so a slow SMTP server slows the write that triggered it. Detaching the send would drop messages when the process exits, which is worse. Use an adapter that hands off quickly, or a provider API rather than raw SMTP.

A failed send is not retried. Every failure is caught, logged through payload.logger.error, and the order saves regardless. There is no queue and no second attempt. Losing a receipt is worse than losing the sale, but a delivery guarantee is a different piece of work.

Delivery is only as good as your adapter. This package composes a message and hands it to payload.sendEmail. Whether it arrives, and whether it lands in a spam folder, is your adapter, your domain and your SPF, DKIM and DMARC records. With no adapter configured, Payload logs the attempt and sends nothing.

Only status changes are detected. A change to any other field sends nothing, by design. A status changed directly in the database, outside Payload, runs no hook and sends nothing.

Nothing records what was sent. There is no send log on the order, so an order updated twice to the same status in two separate writes sends once, but an order moved completed then processing then completed sends twice. If you need transition history, that belongs in a package about transitions.

The amount format is fixed. {{amountFormatted}} is always the decimal value, a space, and the currency code. It is not localised and uses no Intl formatting. A function template receives the raw amount and currency and can format them however you like.

License

MIT. Copyright George Vasiliades, https://github.com/Poseidonas

Similar plugins