Restock for Payload: supplier lists, purchase orders and receiving, fed by your stock levels, with copy-ready orders for suppliers that have no API.
Status: early. 0.2.0 is the latest release. Releases go to npm as @extantape/payload-plugin-restock. 70 tests pass, most against a real MongoDB in memory on Payload 3.92 (on a single-node replica set, with Kitting 0.2.1 from npm and once with Kitting's 0.1 behavior, no restockNeeds, and on a standalone server with no transactions), and the rest with fakes or no database. They cover suppliers, supplier items and purchase orders, the order life cycle and who may move it, site isolation, drafting from stock levels, receiving into Kitting, shipments and marking them delivered, the CSV, JSON and PDF exports, and the write check, which is compared with MongoDB's own answer to the same query and sent raw request bodies over REST. The write check's rules for SQL databases are reasoned from Payload's SQL adapter code and haven't been run against one. On 2026-11-09 a session also checked it in a browser, on a local copy of a real site with made-up suppliers, using the keyboard. It checked the place-this-order panel, receiving with a lot number, the Arrived list and confirming a delivery. No errors were logged. Not checked yet: a screen reader, copying to the clipboard in a normal browser, a real supplier order, and use by anyone outside these tests. Kitting's "Today" line shows arrivals from Kitting 0.2 on; to staff limited to some sites, from Kitting 0.3.0 and Restock 0.1.2 on, since it needs the order's site that arrived now returns.
Restock never buys anything and never stores passwords or card numbers. It drafts; a person checks, approves and places the order.
- Suppliers: name, order email, phone, website, usual days to deliver, how they take orders (quick-order page, CSV, email, their website, phone), the order page, a minimum order value, and ordering notes. If your app already has a
supplierscollection (Kitting adds one), Restock adds these fields to it instead of making a second list. - Supplier items (
supplier-items): the supplier's item or model number, a description, what it's sold as ("box of 100") and how many are in one, the minimum order in packs, the price and the date it was seen, and the product page. With Kitting, each can be linked to the supply it restocks. - Purchase orders (
purchase-orders): one supplier, with lines of items and packs. They're numbered PO-0001, PO-0002 and so on per site.- Totals: prices are copied from the item when a line is added, and the estimated total says whether every line has a price.
- Life cycle: draft, then approved, then ordered (with who, when and the supplier's order number), then partly received or received. Cancelled is possible until it's received.
- By hand: a draft can be approved or cancelled, an approved order sent back to draft, ordered or cancelled, and an ordered one cancelled. Receiving moves it on.
- Locked after the draft: lines can only change while it's a draft.
- History: every status change is kept, with who, when and an optional note.
- Deleting: only drafts can be deleted. Anything further is cancelled instead, so its history stays.
- Drafting (
draftOrders(payload, { scope }), orPOST /api/restock/draftfor people who manage that site): one draft per supplier.- What to buy: with Kitting, from what it says to buy. Without it, from your own
needsfunction. - Which item: a supply's preferred supplier item, the cheapest per unit if there are several.
- How many: rounded up to whole packs and the minimum, after taking off what's already on approved or ordered orders. Each line says why, for example "below its level (40 of 100 each); 500 each in packs of 200".
- Existing drafts: an open draft only gets lines for new items; it's never overwritten.
- Left over: supplies with nothing to buy them from are listed, so you can add a supplier item.
- Never further: nothing is approved or ordered by Restock.
- What to buy: with Kitting, from what it says to buy. Without it, from your own
- Placing an order (on each purchase order's page, and
orderOutputs(payload, id)). Restock never places it: you do, with one of these.- Copy for Quick Order: one "ITEM, QUANTITY" line per item (or with a space or tab), as the supplier's quick-order page asks, with a warning when there are more lines than it takes at a time. ULINE's page takes a comma or a space, and its cart holds 95 items.
- Download PDF: a proper purchase order, with the site's organization name, the order number and date, the supplier, ship to and bill to (from the site's Restock settings, never hard-coded), the lines, the total, notes, the contact, who approved it and the site's terms.
- Real text, tagged for screen readers (headings, a table with header cells, the language and title).
- Page numbers on long orders, sized for US Letter or A4.
- Made with PDFKit's built-in Helvetica, so there are no font files to manage.
- Download CSV: one line per item: supplier item number, description, quantity, what it's sold as, pack size, unit price and line total. It opens cleanly in Excel and Numbers (UTF-8 with a byte-order mark), and cells a spreadsheet could run as a formula are defused.
- Download JSON: the whole order, in a stable, documented format (docs/purchase-order-json.md). It's also what a cart helper reads.
- All three come from
GET /api/restock/order/:id/pdf(or/csv,/json), for people who may read the order. - Email draft: opens in your email app with the order filled in. Nothing is sent until you send it.
- Links: to their order page and to each product page (http and https only).
- Receiving (on an ordered order's page,
receiveOrder(payload, id, lines)andPOST /api/restock/receive): what arrived, in whole packs per line, with a lot number and use-by date where the supply tracks lots.- More than ordered is refused.
- Status: the order becomes partly received or received, with who and when in its history.
- With Kitting: each line linked to a supply adds stock through Kitting's own movements, converted from packs to the supply's unit and referenced with the order number. So Kitting's access check, lots and alerts all apply.
- All or nothing: a receipt that's refused writes nothing.
- Shipments and arrivals. Once an order is placed, staff add its tracking numbers, one per parcel (a supplier may split an order). They show on the order page, the PDF and the JSON.
- Tracking: with
tracking: { track }, Restock asks your tracking service to follow each new number. When it says delivered, your app callsmarkDelivered(payload, { trackerId, scope }). Without a service, staff mark a parcel delivered by hand, on an order they may manage, and only that order's shipments are looked at. - A delivery never adds stock. It puts the order on Arrived, please confirm, on the Restock overview (
/admin/restock) and at the top of Kitting's Today. Withnotify, staff get one email per delivered parcel. - For other plugins:
config.custom.restock.arrived({ payload, user?, scope? })lists those orders as{ id, number, supplier, deliveredAt, scope }.scopeis the order's site, the ID inscopeField(nullwithout one), so Kitting can show staff limited to some sites only their own sites' deliveries. Withuser, only orders that person may receive are listed. - Confirming: on the order, "Yes, I received this package: add the supplies" adds exactly what's still to come, in one click. "Something's missing or damaged" opens the receive form, filled in, with a note. Supplies with lots (reagents) go straight to the form: the lot number and use-by are required, and Restock never makes them up.
- Safety: only people who may receive see these controls. Every receipt is recorded with who confirmed it. The same delivered event twice changes nothing, and a tracker from another site is refused. Marking by hand, a number that isn't on that order is simply not found, wherever else it is.
- Cost: EasyPost lists its Tracking API at "$0.01–$0.03 per shipment" on its pricing page, and says trackers for labels bought through EasyPost are free. It doesn't publish a price for a tracker on a label bought elsewhere, such as a supplier's UPS number. Check with EasyPost or on your EasyPost bill before relying on a figure (checked 2026-11-09).
- Tracking: with
- For a cart helper (a console app later, or your own):
GET /api/restock/cart/orders?scope=lists approved orders with their quick-order lines and links, andPOST /api/restock/cart { order, status: 'filled' | 'failed', note }records whether the cart was filled. A failure needs a reason. Both are for people withapproveaccess, only for approved orders, and nothing else on the order can change through them. Restock still never places an order: a person checks the cart and checks out. - Restock settings (
restock-settings, one per site): the organization name, ship-to and bill-to addresses, a contact, the paper size, and terms printed at the foot of every order. - Access:
managedrafts and receives,approveapproves and marks orders as ordered, andreadsees them. WithscopeField, everything stays inside one site. An order can't use another supplier's items, and nothing links across sites.- Only
trueor a query counts. Each of the three must answer exactlytrue, or a query ({ tenant: { in: [...] } }), which is then applied to the order. Anything else is a no:1,'yes', an empty or malformed query ({ tenant: false }), a query on a field orders don't have, or an error thrown. A query with a blank or missing value, such as{ tenant: { equals: null } }or{ tenant: { not_in: [] } }, is a no too. The endpoints answer 403, never 500, and the/admin/restockpage reads nothing for that person. Returnfalsefor a person with no sites. - Writes are checked before they're saved. When
manageanswers with a query, each create or update on Restock's collections is checked against it in memory, in Restock's lastbeforeChangehook, or it's refused with a 403 and nothing is written. The document checked is the stored one with the submitted values over it, read only from the submitted data's own plain values. The check converts nothing, and it allows a write only when all of these hold. A query allows writes only for a signed-in person fromuserSlug.- Plain data: the submitted data must be plain JSON-like values all the way down. A key named
__proto__,constructor,prototype,toJSONortoBSONat any depth, a getter, a class instance, a Proxy, a function or a symbol key is refused. - Operators and fields:
equals,in,not_equals,not_inandexists, withandandor, on top-level fields that are text, textarea, email, select, radio, number or checkbox, or a relationship or upload to one collection. Not localized or virtual fields, no field named like something every JavaScript object has (constructor,toStringand the like), and noexistson a has-many relationship.idworks on updates only. - Exact stored values: every value in the write and in the query is in the form the database stores. Numbers are numbers and checkboxes are
trueorfalse. IDs are text or numbers, by the collection's ID type, spelled exactly as stored (MongoDB ObjectIds in lowercase), and belong to documents that exist. Relationships hold IDs, not populated documents. An ID innot_equalsornot_inmust exist too. - Exact text: with a
collationset on the MongoDB adapter,not_equalsandnot_inon text are refused. - No later changes: Restock's check must be the last collection
beforeChangehook, and nothing may change a value after it. So, on that collection: nobeforeChangehook on any field, tab or block at any depth (Payload's own row IDs on arrays and blocks are fine), including blocks used throughblockReferencesand, once the collection has any blocks field, every block in the config'sblocks; no rich text editor withbeforeChangehooks; only Payload's built-in field types; and novalidatefunction that changes the data it's given. Anything else the check can't read refuses query answers. Put your hooks before Restock's inoverrides, or answertrue. At start-up Restock logs one warning for each of its collections where a query answer will always be refused, with the reason. - Empty fields: an empty field matches
not_equalsandexists: false, and an empty relationship matchesnot_in. An empty plain field never matchesnot_in, and an empty string matches neitherexists: truenorexists: false, since databases differ there.
- Plain data: the submitted data must be plain JSON-like values all the way down. A key named
- Server code. Code that overrides access and passes no
userneeds no change. Code that overrides access but passes a person asuseris checked against that person'smanage. Where it must write outside their sites, setcontext: { restockTrusted: true }(exported asRESTOCK_TRUSTED) on that request, and only there. - The cart list is refused when
approveanswers no. A query lists only the orders it allows. - One answer for what a person can't see. A link to a supplier or item that doesn't exist and one on another site get the same answer, and an order line whose item is missing, on another site or from another supplier gets one message that names nothing from the item.
- Only
On its own: Restock needs only Payload. It makes its own suppliers list, and drafts orders from a needs function you give it. Receiving then moves the order along and keeps its history, but adds stock nowhere, since there's no stock to add to. Run payload generate:importmap for the order page.
Needs: Payload ^3.80.0, @payloadcms/next ^3.80.0 and React >=19 as peer dependencies. Kitting (@extantape/payload-plugin-kitting >=0.1.0) is an optional peer, found through config.custom.kitting. No other EXTANT APE plugin is required.
Works with:
- Kitting: with Kitting before it in
plugins, Restock adds its fields to Kitting's suppliers, drafts from Kitting'srestockNeeds, and receives into Kitting's stock log, lots and alerts. It finds Kitting throughconfig.custom.kitting, and the contract is in docs/contracts/kitting-restock.md. Kitting's suppliers keep Kitting's own access rules, so Restock's site check covers only the collections Restock makes: set Kitting's supplier access so each person reaches only their own sites. - Labels: Labels 0.1 is out, and a receiving label for each received order is planned for its 0.3, offered through
config.custom.labels.providers.
Carrier tracking comes from your own code through tracking.track and markDelivered (docs/contracts/restock-tracking.md). No other plugin is involved.
Color Theory: no direct link. Its order page uses Payload's --theme-* colors, so it follows Color Theory's admin colors when its applyToAdmin option is on.
Family: Restock sits in the Fulfillment family, with Kitting, Sample Kits, Shipping, Scan, Labels, Wizards, Custody and Sequences, though the families are a working draft and Fulfillment is due to be split into different groups.
Run payload generate:importmap after adding it: the order page has a component.
import { restockPlugin } from '@extantape/payload-plugin-restock'
export default buildConfig({
plugins: [
// kittingPlugin({ … }), // optional; put it before Restock
restockPlugin({
access: { manage: isStaff, approve: isBuyer, read: isStaff },
}),
],
})npm run dev starts a small local app with Restock and Kitting on a throwaway in-memory database, filled with made-up suppliers and supplies. It signs you in as made-up staff, listens on this computer only, and deletes everything when you press Ctrl+C. Nothing is ever sent: emails are written to the terminal.
npm install
npm run dev # try it: http://127.0.0.1:3200/admin/restock, made-up data, deleted on Ctrl+C
npm test # Vitest with an in-memory MongoDB replica set
npm run typecheck
npm run build
npm run leak-checkMIT. See LICENSE.