Assigns each order a short formatted number such as ORD-01042 in sequence. It adds an order number field and a hidden sequence field to the orders collection, plus a closed reservations collection that claims each value in its own transaction. Requires Payload 3.88 or newer and works with the ecommerce plugin or any orders collection on PostgreSQL or MongoDB.
Human readable sequential order numbers for Payload ecommerce, unique under concurrency.
Installation
npm i payload-order-numbers1
Stars
0
Forks
0
Open Issues
2 weeks ago
Last Updated
14
Weekly Downloads
v1.0.2
npm Version
16.3 KB
Unpacked Size
0
Dependencies
10 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 1 |
| Dec 4, 2026 | 1 |
| Dec 3, 2026 | 1 |
| Dec 2, 2026 | 1 |
| Dec 1, 2026 | 1 |
| Nov 30, 2026 | 1 |
| Nov 29, 2026 | 1 |
| Nov 28, 2026 | 1 |
| Nov 27, 2026 | 1 |
| Nov 26, 2026 | 1 |
| Nov 25, 2026 | 1 |
| Nov 24, 2026 | 1 |
| Nov 23, 2026 | 1 |
| Nov 22, 2026 | 1 |
| Nov 21, 2026 | 1 |
| Nov 20, 2026 | 1 |
| Nov 19, 2026 | 1 |
| Nov 18, 2026 | 1 |
| Nov 17, 2026 | 1 |
| Nov 16, 2026 | 1 |
| Nov 15, 2026 | 1 |
| Nov 14, 2026 | 1 |
| Nov 13, 2026 | 1 |
| Nov 12, 2026 | 1 |
| Nov 11, 2026 | 1 |
| Nov 10, 2026 | 1 |
| Nov 9, 2026 | 1 |
| Nov 8, 2026 | 1 |
| Nov 7, 2026 | 1 |
| Nov 6, 2026 | 1 |
| Nov 5, 2026 | 1 |
| Nov 4, 2026 | 1 |
| Nov 3, 2026 | 1 |
| Nov 2, 2026 | 1 |
| Nov 1, 2026 | 1 |
| Oct 31, 2026 | 1 |
| Oct 30, 2026 | 1 |
| Oct 29, 2026 | 1 |
| Oct 28, 2026 | 1 |
| Oct 27, 2026 | 1 |
| Oct 26, 2026 | 1 |
| Oct 25, 2026 | 1 |
| Oct 24, 2026 | 1 |
| Oct 23, 2026 | 1 |
| Oct 22, 2026 | 1 |
| Oct 21, 2026 | 1 |
| Oct 20, 2026 | 1 |
| Oct 19, 2026 | 1 |
| Oct 18, 2026 | 1 |
| Oct 17, 2026 | 1 |
| Oct 16, 2026 | 1 |
| Oct 15, 2026 | 1 |
| Oct 14, 2026 | 1 |
| Oct 13, 2026 | 1 |
| Oct 12, 2026 | 1 |
| Oct 11, 2026 | 1 |
| Oct 10, 2026 | 1 |
| Oct 9, 2026 | 1 |
| Oct 8, 2026 | 1 |
| Oct 7, 2026 | 1 |
| Oct 6, 2026 | 1 |
| Oct 5, 2026 | 1 |
| Oct 4, 2026 | 1 |
| Oct 3, 2026 | 1 |
| Oct 2, 2026 | 1 |
| Oct 1, 2026 | 1 |
| Sep 30, 2026 | 1 |
| Sep 29, 2026 | 1 |
| Sep 28, 2026 | 1 |
| Sep 27, 2026 | 1 |
| Sep 26, 2026 | 1 |
| Sep 25, 2026 | 1 |
| Sep 24, 2026 | 1 |
| Sep 23, 2026 | 1 |
| Sep 22, 2026 | 1 |
| Sep 21, 2026 | 1 |
| Sep 20, 2026 | 1 |
| Sep 19, 2026 | 1 |
| Sep 18, 2026 | 1 |
| Sep 17, 2026 | 1 |
| Sep 16, 2026 | 1 |
| Sep 15, 2026 | 1 |
| Sep 14, 2026 | 1 |
| Sep 13, 2026 | 1 |
| Sep 12, 2026 | 1 |
| Sep 11, 2026 | 1 |
| Sep 10, 2026 | 1 |
| Sep 9, 2026 | 1 |
| Sep 8, 2026 | 1 |
| Sep 7, 2026 | 1 |
| Sep 6, 2026 | 1 |
11−10 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 11 |
| Dec 4, 2026 | 15 |
| Dec 3, 2026 | 20 |
| Dec 2, 2026 | 24 |
| Dec 1, 2026 | 24 |
| Nov 30, 2026 | 24 |
| Nov 29, 2026 | 24 |
| Nov 28, 2026 | 34 |
| Nov 27, 2026 | 39 |
| Nov 26, 2026 | 210 |
| Nov 25, 2026 | 205 |
| Nov 24, 2026 | 203 |
| Nov 23, 2026 | 201 |
| Nov 22, 2026 | 199 |
| Nov 21, 2026 | 189 |
| Nov 20, 2026 | 180 |
| Nov 19, 2026 | 6 |
| Nov 18, 2026 | 8 |
| Nov 17, 2026 | 8 |
| Nov 16, 2026 | 9 |
| Nov 15, 2026 | 7 |
| Nov 14, 2026 | 7 |
| Nov 13, 2026 | 8 |
| Nov 12, 2026 | 9 |
| Nov 11, 2026 | 7 |
| Nov 10, 2026 | 9 |
| Nov 9, 2026 | 8 |
| Nov 8, 2026 | 12 |
| Nov 7, 2026 | 14 |
| Nov 6, 2026 | 13 |
| Nov 5, 2026 | 13 |
| Nov 4, 2026 | 13 |
| Nov 3, 2026 | 10 |
| Nov 2, 2026 | 13 |
| Nov 1, 2026 | 9 |
| Oct 31, 2026 | 7 |
| Oct 30, 2026 | 7 |
| Oct 29, 2026 | 4 |
| Oct 28, 2026 | 4 |
| Oct 27, 2026 | 6 |
| Oct 26, 2026 | 5 |
| Oct 25, 2026 | 5 |
| Oct 24, 2026 | 6 |
| Oct 23, 2026 | 5 |
| Oct 22, 2026 | 9 |
| Oct 21, 2026 | 10 |
| Oct 20, 2026 | 9 |
| Oct 19, 2026 | 8 |
| Oct 18, 2026 | 8 |
| Oct 17, 2026 | 10 |
| Oct 16, 2026 | 10 |
| Oct 15, 2026 | 9 |
| Oct 14, 2026 | 8 |
| Oct 13, 2026 | 7 |
| Oct 12, 2026 | 7 |
| Oct 11, 2026 | 8 |
| Oct 10, 2026 | 6 |
| Oct 9, 2026 | 6 |
| Oct 8, 2026 | 4 |
| Oct 7, 2026 | 4 |
| Oct 6, 2026 | 9 |
| Oct 5, 2026 | 8 |
| Oct 4, 2026 | 10 |
| Oct 3, 2026 | 10 |
| Oct 2, 2026 | 15 |
| Oct 1, 2026 | 14 |
| Sep 30, 2026 | 14 |
| Sep 29, 2026 | 13 |
| Sep 28, 2026 | 14 |
| Sep 27, 2026 | 12 |
| Sep 26, 2026 | 14 |
| Sep 25, 2026 | 9 |
| Sep 24, 2026 | 9 |
| Sep 23, 2026 | 9 |
| Sep 22, 2026 | 8 |
| Sep 21, 2026 | 9 |
| Sep 20, 2026 | 11 |
| Sep 19, 2026 | 11 |
| Sep 18, 2026 | 12 |
| Sep 17, 2026 | 15 |
| Sep 16, 2026 | 17 |
| Sep 15, 2026 | 14 |
| Sep 14, 2026 | 13 |
| Sep 13, 2026 | 10 |
| Sep 12, 2026 | 7 |
| Sep 11, 2026 | 9 |
| Sep 10, 2026 | 7 |
| Sep 9, 2026 | 6 |
| Sep 8, 2026 | 9 |
| Sep 7, 2026 | 15 |
| Sep 6, 2026 | 21 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1339781367-root)<a href="https://payloaddirectory.dev/plugins/1339781367-root"><img src="https://payloaddirectory.dev/badge/1339781367-root.svg" alt="Payload Directory"></a>README
Gives every Payload order a short, human readable number such as ORD-01042, assigned in sequence and unique under concurrency, so that a customer and a shop can refer to the same order out loud.
@payloadcms/plugin-ecommerce and with any collection that holds ordersRequires 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-numbers
import { orderNumbersPlugin } from 'payload-order-numbers'
export default buildConfig({
plugins: [
orderNumbersPlugin({
prefix: 'ORD-',
padding: 5,
startAt: 1000,
}),
],
})
The first order becomes ORD-01000, the next ORD-01001, and so on.
A Payload document identifier is not something you can read to a customer over the phone. Measured on a live Payload 3.88 install:
| Database | What an order id looks like |
|---|---|
| MongoDB | 6a85cce9ce631c0034f52d84, a 24 character ObjectId |
| PostgreSQL | 1, 2, 3, an auto incrementing integer |
The MongoDB identifier is unusable as an order reference. The PostgreSQL identifier is readable, but it starts at 1, carries no prefix, and tells anyone who sees it exactly how many orders the shop has taken.
The first design read the highest existing number and added one, inside a beforeChange hook. Measured with 25 orders created in the same instant:
| Design | Orders that succeeded | Why |
|---|---|---|
beforeChange, highest plus one | 5 of 25 | every request reads the same highest value inside its own transaction |
afterChange with retry | 3 of 25 | retrying inside the same aborted transaction cannot succeed |
| Reservation committed separately | 25 of 25 | each number is claimed in its own transaction and is immediately visible |
No design ever produced a duplicate. The unique index held in every run. The failures were refusals, not corruption.
Before an order is written, the plugin claims the next free value by inserting it into a small reservations collection. That insert commits on its own, so a second order arriving at the same moment sees the claim and takes the next value. The unique index on the order number is the final guarantee, not the first line of defence.
Verified with 25 orders created simultaneously:
| Database | Orders with a number | Unique | Gaps |
|---|---|---|---|
| MongoDB | 25 of 25 | 25 of 25 | none |
| PostgreSQL | 25 of 25 | 25 of 25 | none |
| Option | Default | Meaning |
|---|---|---|
attempts | 50 | How many values to try before giving up. Each attempt is one insert |
disabled | false | Stops assigning numbers but keeps the fields, so the database keeps its shape |
fieldName | 'orderNumber' | Field holding the formatted number |
ordersSlug | 'orders' | Slug of the orders collection |
padding | 0 | Minimum width of the numeric part, left padded with zeros |
prefix | '' | Text placed before the number |
reservationsSlug | 'order-number-reservations' | Collection holding claimed values |
sequenceFieldName | 'orderSequence' | Numeric field the sequence is read from |
startAt | 1 | Value given to the first order |
suffix | '' | Text placed after the number |
A value that cannot be used is replaced by its default rather than being applied. A negative padding becomes 0, a startAt of 0 becomes 1, and 4.9 becomes 4. Nothing is silently reinterpreted: -5 never becomes 5.
| Collection | Field | Type | Notes |
|---|---|---|---|
| your orders collection | orderNumber | text | unique, indexed, read only in the admin sidebar |
| your orders collection | orderSequence | number | unique, indexed, hidden |
order-number-reservations | sequence | number | unique, indexed. Collection hidden, no API access |
The reservations collection is closed to create, read, update and delete through the API. It is written only by the plugin.
PostgreSQL needs a large enough connection pool. Claiming a number opens a second connection while the order's own transaction holds the first. With the pg default of 10, ten simultaneous orders exhaust the pool and the eleventh waits forever. Measured exactly:
| Simultaneous orders | Result with the default pool of 10 |
|---|---|
| 2, 4, 6, 8, 10 | all succeed |
| 15 | 3 succeed, the rest time out |
Set the pool to at least twice the number of orders you expect in the same instant:
postgresAdapter({
pool: { connectionString: process.env.DATABASE_URI, max: 60 },
})
MongoDB is not affected and needs no change.
Numbers can have gaps. A claimed value is not returned if the order then fails to save. The sequence stays ascending and unique, but it is not a gapless accounting series. If you need one for invoices, that is a different guarantee and belongs in a different package.
Existing orders are not renumbered. The plugin only assigns a number when an order is created. Orders already in the database keep an empty orderNumber.
Under extreme load the order still saves. If all attempts are exhausted the order is written without a number and an error is logged. Losing a sale is worse than losing a label.
MIT. Copyright George Vasiliades, https://github.com/Poseidonas
ecommerce
Ecommerce utilities for Payload with idempotent Stripe confirmation, orders, carts and inventory handling
10019.0k/wk46.1kv3 v4
payload stock reservation
Validates variant stock and price at checkout and holds stock until payment settles or the hold expires
76152/wk1v3
payload coupons
Coupon codes with percentage and fixed discounts for Payload ecommerce, calculated in integer minor units
76144/wk2v3
payload fulfillment
Extra order states, transition history, internal notes and tracking fields for Payload ecommerce orders
7332/wk1v3
payload ecommerce
Products, carts, orders and coupons for Payload 3 with server-side helpers and stock tracking
72537/wk2v3
payload reviews
Product reviews for Payload ecommerce with verified purchase flags, moderation and exact aggregate ratings
7317/wk2v3