Document Numbers
Module: Magenx_DocumentNumber · admin and order flow only, no GraphQL schema of its own
Document Numbers replaces Magento’s plain counters, such as 000000123, with numbers you design: ORD-2026-00045 for an order, INV-2026-00045 for its invoice, CM-2611-0001 for a credit memo. Finance can read the year and the document type from the number, and a competitor can no longer work out your order volume from two order numbers.
Shoppers see the new number everywhere they see an order number today: the confirmation page, emails, printable documents and their order history. Only the number people see changes. Magento’s internal record ids and the links between records stay as they are.
How it works
Section titled “How it works”Every new order, invoice, shipment and credit memo gets its number at the moment it is created. If a number cannot be built for any reason, the document gets Magento’s standard number instead, and the event is logged. Numbering never stops a checkout.
Payment methods that need the order number before the order exists get the same number the order ends up with.
Patterns
Section titled “Patterns”A pattern is fixed text plus placeholders. Fixed text may use letters, digits, -, _ and ..
| Placeholder | Becomes | Example |
|---|---|---|
{counter} | The counter, left-filled with zeros to the padding | 00045 |
{yyyy} or {year} | Four-digit year | 2026 |
{yy} | Two-digit year | 26 |
{mm} | Month | 11 |
{dd} | Day | 04 |
{store} | Store view code | default |
{website} | Website code | base |
Dates use the store’s time zone. Each counter has a start value, a step, a padding and a reset period: never, yearly, monthly or daily. A counter is shared by the whole installation, by each website, or by each store view. A counter that outgrows its padding gets one digit wider. It is never cut.
When you save a pattern, the admin rejects it, with a message naming the fix, if:
- it has no
{counter}, or more than one; - the counter resets but the pattern lacks the matching date placeholders, for example a yearly reset without
{yyyy}; - the counter is per website without
{website}or{store}, or per store view without{store}; - the number could be longer than 32 characters;
- the fixed text holds a character other than those listed above.

Same as order
Section titled “Same as order”Invoices, shipments and credit memos can take the number of their order. The order pattern’s leading fixed text is swapped for the document prefix, and the second and later documents of one order get a suffix.
| Order | Document | Number |
|---|---|---|
ORD-2026-00045 | First invoice | INV-2026-00045 |
ORD-2026-00045 | Second invoice | INV-2026-00045-2 |
ORD-2026-00045 | First shipment | SHP-2026-00045 |
100000123 (placed before you switched numbering on) | First invoice | INV-100000123 |
Cancelled documents count, so a suffix is never reused. If the result would be longer than 32 characters, the document’s own-counter pattern is used instead.

Set up
Section titled “Set up”- Go to Stores > Configuration > Magenx > Document Numbers.
- Under Orders, set the pattern, padding, reset and Counter Shared By.
- Under Invoices, Shipments and Credit Memos, choose Same as order or Own counter, and set the document prefix or the pattern.
- Save. Check the Next Numbers table: it shows the next number for each store view and type without using one up.
- Switch to the website scope and set Enable Document Numbers to Yes.

Settings changes apply to documents created after the save. Existing documents keep their numbers, also when you switch numbering off.


Counters
Section titled “Counters”Stores > Settings > Document Number Counters lists every counter with its last value and the next number. Use Set the next value to continue a series from your previous system, for example to make the next invoice INV-2026-04813. This page has its own permission, separate from the settings.

Limits
Section titled “Limits”- Gaps are allowed, duplicates are not. A number reserved for a cart that is never ordered is not reused.
- Strictly gap-free invoice series are not supported.
- When an admin edits an order, the replacement order keeps the original number plus Magento’s revision suffix, for example
ORD-2026-00045-1. - A number supplied by an integration is kept. If another document of that type already uses it, the save is refused.
- More than 5 fallbacks to the standard number for one document type within an hour raise an admin notification. So does a counter that reaches 90% of its padding.
User flows
Section titled “User flows”Merchant sets up numbering
- Admin user opens numbering settings for a store scope.
- For orders, enters pattern "ORD-{year}-{counter}", padding 5, start 1, step 1, reset yearly, scope whole installation.
- For invoices, picks "same as order", document prefix "INV-". Same for shipments ("SHP-") and credit memos ("CM-").
- Settings page shows the next number for each type, e.g. "ORD-2026-00001", "INV-2026-00001".
- Admin user saves. Validation passes. Feature switches on. Next order placed gets "ORD-2026-00001".
Shopper places an order
- Shopper reaches payment. If the payment method needs the number in advance, the cart gets a reserved number from the pattern.
- Shopper places the order. The order saves with the reserved number, or a new pattern number if none was reserved.
- Confirmation screen, confirmation email and order history show the pattern number.
Merchant invoices, ships and refunds ("same as order")
- Order "ORD-2026-00045" is invoiced. Invoice gets "INV-2026-00045".
- A second, partial invoice for the same order gets "INV-2026-00045-2".
- First shipment gets "SHP-2026-00045"; second gets "SHP-2026-00045-2".
- First credit memo gets "CM-2026-00045".
- Order view lists all child documents; each number shows its order at a glance.
Own-counter child documents
- Credit memos use own counter "CM-{yy}{mm}-{counter}", padding 4, monthly reset.
- First credit memo in November 2026 gets "CM-2611-0001"; first in December gets "CM-2612-0001".
Merchant continues an existing series
- Merchant migrated from another system whose last invoice was "INV-2026-04812".
- Admin user sets the invoice counter's next value to 4813.
- Next invoice gets "INV-2026-04813". The change is recorded with the admin user and time.
Numbering fails
- Pattern number cannot be produced (e.g. counter storage unavailable, number too long).
- The document saves with its standard number. The user sees no error.
- A warning log entry names the document type, store and reason. Admin notification appears.
These always hold:
- Internal identifiers are never created, changed or exposed by this feature.
- A document number is unique within its document type across the whole installation.
- If a rendered number already exists, the counter advances until a free number is found (max 1 000 attempts, then fallback).
- A document number never changes after creation.
- Numbering never causes a document save to fail.
- A counter value is used at most once per counter.
- Order placement, invoicing, shipping and refunding behave identically with the feature on or off, apart from the number.
- Counter value = start value for the first document in a period; previous value + step after that.
- Rendered counter = value left-padded with zeros to padding width; never truncated.
- Period boundaries use store time: yearly at 1 January 00:00, monthly at day 1 00:00, daily at 00:00.
- Date placeholders and period use the same moment: when the number is assigned (for orders with a reserved number, when it was reserved).
- Same-as-order: number = swap(order number, document prefix) + (suffix if index ≥ 2, or always if configured), index = count of that type for the order including this one.
- Settings resolve narrowest scope first: store view, then website, then installation.
- With the feature off, every document gets its standard number.
- Switching off and on again resumes the stored counters; no value is reused.
- Removing the feature leaves every document number as it is.
- Customer-visible numbers in confirmation screen, email, order history and printable documents are identical for the same document.
Edge cases
Section titled “Edge cases”| Situation | What happens |
|---|---|
| 50 orders placed concurrently on one counter | 50 distinct, consecutive-or-gapped numbers; no duplicate; no failed order. |
| Number reserved 31 Dec 23:59 store time, order placed 1 Jan 00:01 | Order keeps the reserved number with the old year. |
| Cart with reserved number abandoned | Number is not reused; a gap remains. |
| Counter lowered to a value already used | Used numbers skipped; next free number assigned. |
| Counter storage unavailable during order placement | Order saves with standard number; fallback logged. |
| Counter grows past padding (99 999 → 100 000 at padding 5) | Number becomes one digit longer; no truncation. |
| Rendered number would exceed 32 characters | Fallback; logged. |
| Pattern changed between two orders | First order keeps old-format number; second uses new pattern. |
| Same-as-order invoice for an order whose number does not start with the current order prefix | Document prefix is put in front of the whole order number. |
| Two invoices for one order created concurrently | Distinct suffixes; no duplicate. |
| Admin edits order "ORD-2026-00045" twice | Revised orders "ORD-2026-00045-1", then "-2"; order counter unchanged. |
| Integration supplies an existing number | Document rejected with a duplicate-number error; no counter change. |
| Two store views share a counter scope of "per store view" but pattern has no store-specific part | Save rejected. |
| Yearly reset with no year placeholder | Save rejected. |
| Feature switched off with a digits-only pattern, standard number then equals an existing pattern number | Standard numbering's own duplicate rule applies; warning was shown at save. |
| Credit memo in same-as-order mode for an order with no invoice | Gets "CM-" + order number body; no dependency on invoice numbers. |
| Daylight-saving change at reset boundary | Period computed in store time; exactly one reset. |
Who it applies to
Section titled “Who it applies to”- All four document types, all store views, all order sources (storefront, admin, API, integrations).
- Each document type and store scope can be switched on separately.
- Documents created before switch-on keep their standard numbers.
Out of scope
Section titled “Out of scope”- Renumbering documents that already exist.
- Strictly gap-free series (a number consumed by an abandoned checkout is not reused). See Open questions.
- Numbering for other document types (quotes, returns, gift cards, customer accounts).
- Per-payment-method or per-customer-group patterns.
- Fiscal-device or tax-authority registration of numbers.
- Changing how internal identifiers are generated.
Install
Section titled “Install”composer require magenxcommerce/module-document-numberbin/magento module:enable Magenx_DocumentNumberbin/magento setup:upgradebin/magento setup:di:compile # production mode onlybin/magento cache:flush- PHP
~8.4.0||~8.5.0, Magento 2.4.8.
Configuration
Section titled “Configuration”Stores > Configuration > Magenx > Document Numbers
General
Gives new orders, invoices, shipments and credit memos a number built from the patterns below. Internal ids are never touched; existing documents keep their numbers. If a number cannot be built, the document gets the standard number and the event is logged, so checkout never fails. Counter values: Stores > Settings > Document Number Counters.
| Setting | Default | Scope | Notes |
|---|---|---|---|
Enable Document Numbersmagenx_document_number/ | No | Website | Yes/No. Off: every new document gets the standard number. Counters are kept and resume when switched on again. |
Next Numbersmagenx_document_number/ | empty | Website | Text. |
Orders
| Setting | Default | Scope | Notes |
|---|---|---|---|
Number Ordersmagenx_document_number/ | Yes | Store view | Yes/No. No: orders keep the standard number. |
Patternmagenx_document_number/ | ORD-{yyyy}-{counter} | Store view | Text. Shown when Number Orders = Yes. Fixed text (letters, digits, "-", "_", ".") and placeholders: {counter}, {yyyy} (or {year}), {yy}, {mm}, {dd}, {store} (store view code), {website} (website code). Dates use the store's time zone. At most 32 characters with the counter 3 digits wider than its padding. |
Counter Start Valuemagenx_document_number/ | 1 | Store view | Text. Shown when Number Orders = Yes. First counter value of a new series and after each reset. |
Counter Stepmagenx_document_number/ | 1 | Store view | Text. Shown when Number Orders = Yes. Amount the counter grows per document (1–100). A step above 1 hides how many documents the store creates. |
Counter Paddingmagenx_document_number/ | 6 | Store view | Text. Shown when Number Orders = Yes. Minimum counter width (1–12), left-filled with zeros. A counter that outgrows it gets wider; it is never cut. |
Counter Resetmagenx_document_number/ | never | Store view | Dropdown. Shown when Number Orders = Yes. When the counter returns to the start value, in store time. The pattern must hold the matching date placeholders. |
Counter Shared Bymagenx_document_number/ | global | Store view | Dropdown. Shown when Number Orders = Yes. Per website needs {website} or {store} in the pattern; per store view needs {store}. |
Invoices
| Setting | Default | Scope | Notes |
|---|---|---|---|
Number Invoicesmagenx_document_number/ | Yes | Store view | Yes/No. No: invoices keep the standard number. |
Numbering Modemagenx_document_number/ | same_as_order | Store view | Dropdown. Shown when Number Invoices = Yes. Same as order: built from the order number. Own counter: the pattern below. |
Document Prefixmagenx_document_number/ | INV- | Store view | Text. Shown when Number Invoices = Yes, Numbering Mode = same_as_order. Replaces the order pattern's leading fixed text: order ORD-2026-00045 gives INV-2026-00045. An order number without that text gets the prefix in front. Empty: the order number as is. |
Sequence Suffix Separatormagenx_document_number/ | - | Store view | Text. Shown when Number Invoices = Yes, Numbering Mode = same_as_order. Put between the number and the sequence suffix of the second and later invoices of one order, e.g. "-" gives ...-2. |
First Suffix Numbermagenx_document_number/ | 2 | Store view | Text. Shown when Number Invoices = Yes, Numbering Mode = same_as_order. Suffix of the first document that gets one. |
Suffix on First Documentmagenx_document_number/ | No | Store view | Yes/No. Shown when Number Invoices = Yes, Numbering Mode = same_as_order. Yes: the first document of an order also gets a suffix. |
Patternmagenx_document_number/ | INV-{yyyy}-{counter} | Store view | Text. Shown when Number Invoices = Yes. Fixed text (letters, digits, "-", "_", ".") and placeholders: {counter}, {yyyy} (or {year}), {yy}, {mm}, {dd}, {store} (store view code), {website} (website code). Dates use the store's time zone. At most 32 characters with the counter 3 digits wider than its padding. In same-as-order mode this own-counter pattern is used only when the order-based number would be longer than 32 characters. |
Counter Start Valuemagenx_document_number/ | 1 | Store view | Text. Shown when Number Invoices = Yes. First counter value of a new series and after each reset. |
Counter Stepmagenx_document_number/ | 1 | Store view | Text. Shown when Number Invoices = Yes. Amount the counter grows per document (1–100). A step above 1 hides how many documents the store creates. |
Counter Paddingmagenx_document_number/ | 6 | Store view | Text. Shown when Number Invoices = Yes. Minimum counter width (1–12), left-filled with zeros. A counter that outgrows it gets wider; it is never cut. |
Counter Resetmagenx_document_number/ | never | Store view | Dropdown. Shown when Number Invoices = Yes. When the counter returns to the start value, in store time. The pattern must hold the matching date placeholders. |
Counter Shared Bymagenx_document_number/ | global | Store view | Dropdown. Shown when Number Invoices = Yes. Per website needs {website} or {store} in the pattern; per store view needs {store}. |
Shipments
| Setting | Default | Scope | Notes |
|---|---|---|---|
Number Shipmentsmagenx_document_number/ | Yes | Store view | Yes/No. No: shipments keep the standard number. |
Numbering Modemagenx_document_number/ | same_as_order | Store view | Dropdown. Shown when Number Shipments = Yes. Same as order: built from the order number. Own counter: the pattern below. |
Document Prefixmagenx_document_number/ | SHP- | Store view | Text. Shown when Number Shipments = Yes, Numbering Mode = same_as_order. Replaces the order pattern's leading fixed text: order ORD-2026-00045 gives INV-2026-00045. An order number without that text gets the prefix in front. Empty: the order number as is. |
Sequence Suffix Separatormagenx_document_number/ | - | Store view | Text. Shown when Number Shipments = Yes, Numbering Mode = same_as_order. Put between the number and the sequence suffix of the second and later shipments of one order, e.g. "-" gives ...-2. |
First Suffix Numbermagenx_document_number/ | 2 | Store view | Text. Shown when Number Shipments = Yes, Numbering Mode = same_as_order. Suffix of the first document that gets one. |
Suffix on First Documentmagenx_document_number/ | No | Store view | Yes/No. Shown when Number Shipments = Yes, Numbering Mode = same_as_order. Yes: the first document of an order also gets a suffix. |
Patternmagenx_document_number/ | SHP-{yyyy}-{counter} | Store view | Text. Shown when Number Shipments = Yes. Fixed text (letters, digits, "-", "_", ".") and placeholders: {counter}, {yyyy} (or {year}), {yy}, {mm}, {dd}, {store} (store view code), {website} (website code). Dates use the store's time zone. At most 32 characters with the counter 3 digits wider than its padding. In same-as-order mode this own-counter pattern is used only when the order-based number would be longer than 32 characters. |
Counter Start Valuemagenx_document_number/ | 1 | Store view | Text. Shown when Number Shipments = Yes. First counter value of a new series and after each reset. |
Counter Stepmagenx_document_number/ | 1 | Store view | Text. Shown when Number Shipments = Yes. Amount the counter grows per document (1–100). A step above 1 hides how many documents the store creates. |
Counter Paddingmagenx_document_number/ | 6 | Store view | Text. Shown when Number Shipments = Yes. Minimum counter width (1–12), left-filled with zeros. A counter that outgrows it gets wider; it is never cut. |
Counter Resetmagenx_document_number/ | never | Store view | Dropdown. Shown when Number Shipments = Yes. When the counter returns to the start value, in store time. The pattern must hold the matching date placeholders. |
Counter Shared Bymagenx_document_number/ | global | Store view | Dropdown. Shown when Number Shipments = Yes. Per website needs {website} or {store} in the pattern; per store view needs {store}. |
Credit Memos
| Setting | Default | Scope | Notes |
|---|---|---|---|
Number Credit Memosmagenx_document_number/ | Yes | Store view | Yes/No. No: credit memos keep the standard number. |
Numbering Modemagenx_document_number/ | same_as_order | Store view | Dropdown. Shown when Number Credit Memos = Yes. Same as order: built from the order number. Own counter: the pattern below. |
Document Prefixmagenx_document_number/ | CM- | Store view | Text. Shown when Number Credit Memos = Yes, Numbering Mode = same_as_order. Replaces the order pattern's leading fixed text: order ORD-2026-00045 gives INV-2026-00045. An order number without that text gets the prefix in front. Empty: the order number as is. |
Sequence Suffix Separatormagenx_document_number/ | - | Store view | Text. Shown when Number Credit Memos = Yes, Numbering Mode = same_as_order. Put between the number and the sequence suffix of the second and later credit memos of one order, e.g. "-" gives ...-2. |
First Suffix Numbermagenx_document_number/ | 2 | Store view | Text. Shown when Number Credit Memos = Yes, Numbering Mode = same_as_order. Suffix of the first document that gets one. |
Suffix on First Documentmagenx_document_number/ | No | Store view | Yes/No. Shown when Number Credit Memos = Yes, Numbering Mode = same_as_order. Yes: the first document of an order also gets a suffix. |
Patternmagenx_document_number/ | CM-{yyyy}-{counter} | Store view | Text. Shown when Number Credit Memos = Yes. Fixed text (letters, digits, "-", "_", ".") and placeholders: {counter}, {yyyy} (or {year}), {yy}, {mm}, {dd}, {store} (store view code), {website} (website code). Dates use the store's time zone. At most 32 characters with the counter 3 digits wider than its padding. In same-as-order mode this own-counter pattern is used only when the order-based number would be longer than 32 characters. |
Counter Start Valuemagenx_document_number/ | 1 | Store view | Text. Shown when Number Credit Memos = Yes. First counter value of a new series and after each reset. |
Counter Stepmagenx_document_number/ | 1 | Store view | Text. Shown when Number Credit Memos = Yes. Amount the counter grows per document (1–100). A step above 1 hides how many documents the store creates. |
Counter Paddingmagenx_document_number/ | 6 | Store view | Text. Shown when Number Credit Memos = Yes. Minimum counter width (1–12), left-filled with zeros. A counter that outgrows it gets wider; it is never cut. |
Counter Resetmagenx_document_number/ | never | Store view | Dropdown. Shown when Number Credit Memos = Yes. When the counter returns to the start value, in store time. The pattern must hold the matching date placeholders. |
Counter Shared Bymagenx_document_number/ | global | Store view | Dropdown. Shown when Number Credit Memos = Yes. Per website needs {website} or {store} in the pattern; per store view needs {store}. |
Admin pages and permissions
Section titled “Admin pages and permissions”- Settings > Document Number Counters
Grant these under System > Permissions > User Roles > Role Resources:
| Resource | Under | ID |
|---|---|---|
| Document Numbers Section | Stores > Settings > Configuration | Magenx_DocumentNumber::config |
| Document Number Counters | Stores > Settings | Magenx_DocumentNumber::counters |
GraphQL
Section titled “GraphQL”The module adds no schema. The stock number fields on orders, invoices, shipments and credit memos, guest order lookup by number, and the customer order filter by number all use the new numbers, so the storefront needs no change.
Glossary
Section titled “Glossary”| Term | Meaning |
|---|---|
| Document | An order, invoice, shipment or credit memo. |
| Document type | One of the four kinds above. |
| Internal identifier | The system key that links records. Never shown as the document number and never changed by this feature. |
| Document number | The human-readable number shown to people and integrations. This feature controls it. |
| Standard number | The document number the platform would assign without this feature. |
| Pattern | Merchant-defined template for a document number, made of fixed text and placeholders. |
| Placeholder | A part of a pattern replaced at creation time: counter, 4-digit year, 2-digit year, month, day, store code, website code. |
| Counter | A whole number that increases for each document of a type within a counter scope and reset period. |
| Padding | Minimum counter width; shorter values are left-filled with zeros. |
| Step | Amount the counter increases per document. |
| Reset period | When the counter returns to its start value: never, yearly, monthly, daily. |
| Counter scope | Which documents share one counter: whole installation, per website, or per store view. |
| Numbering mode | For invoices, shipments and credit memos: "own counter" or "same as order". |
| Same as order | Mode where a child document's number is built from its order's number. |
| Child document | An invoice, shipment or credit memo of an order. |
| Document prefix swap | In "same as order" mode, replace the order's leading fixed text with the child document's fixed text (e.g. "ORD-" becomes "INV-"). |
| Sequence suffix | Text added to the second and later child documents of the same type for one order, e.g. "-2", "-3". |
| Reserved number | An order number given to a cart before the order is saved, for payment methods that need it in advance. |
| Fallback | Assigning the standard number because a pattern number could not be produced. |
| Store time | The date and time in the time zone of the document's store. |