Barcodes
Adds Code 128, EAN-13 and QR code generation to Payload product collections with a printable label page and optional admin print buttons.
Installation
pnpm add payload-barcodes About
Attaches a barcode and a QR code to product documents, drawn from a field the shop picks. The encoders for Code 128, EAN-13 and QR are written from the specification inside the package, so there is no runtime dependency, no image service and no external call. It is built on top of `@payloadcms/plugin-ecommerce` and adds the codes to the collections you name. The plugin registers an `afterChange` hook on each named collection. The hook runs after the document is written, so a transforming field hook (a slug being the usual case) has already done its work, and it records the value, the symbology and a plain explanation when the value cannot be drawn. It writes only when something changed and marks the request so it cannot re-enter itself. A settings global (slug `barcodes` by default) holds the source field name, the format, whether the QR code carries the value or a URL built from it, the URL template and a caption toggle. One endpoint at `/api/barcodes/print` returns a single complete HTML page of labels, black on white, that opens the print dialog on load and keeps each label on one page. The images are never stored. Both codes are drawn when the page is requested, so changing a setting updates every label immediately and nothing in the database goes stale. QR is capped at version 10 (271 bytes at level L, 213 at M), which covers an article number, a SKU or a product URL. Code 128 uses set B only, printable ASCII from space to tilde, and EAN-13 is validated rather than corrected; `completeEan13` is exported if you want to add the check digit yourself. Recording costs a second write on the first save of a new document, since the hook runs after the write. The main entry imports no React, which is what keeps the package on the part of Payload's surface that survives minor releases. `PrintButtons` is opt in from the `payload-barcodes/client` entry and renders exactly Print Barcode and Print QR Code with no styling of its own beyond spacing, so it inherits the admin theme. If the buttons ever break, the printing itself does not.
Package info
- Package name
payload-barcodes- Latest version
1.0.0- Unpacked size
- 50 kB
- License
- MIT
- Weekly downloads
- 150
- Last publish
- Aug 21, 2026
More from Poseidonas
View profileAI Manager
Writes product titles, descriptions, attributes and translations into Payload fields via Claude, ChatGPT, Gemini or Kimi, and skips content it already generated.
EU VAT
Records EU VAT on Payload ecommerce orders: country rates, B2B reverse charge, VIES validation, and OSS reporting totals.
Stock Reservation
Validates variant stock and price before checkout and holds reserved inventory until payment settles, extending the official Payload ecommerce plugin.
Stock Alerts
Sends a shop one email when product or variant inventory crosses a low stock threshold, with backorder handling and a storefront-readable status field.
Shipping Rates
Adds shipping zones, rate calculation, and a quote endpoint to Payload ecommerce shops.
Shipping Classes
Adds weight, dimensions, and shipping class fields to Payload products and variants, storing values canonically in grams and millimetres for cart totalling.