Magento 2 Change Order Number Format: Safe Methods
Custom Order Numbers in Magento 2: Prefixes, Dates & Counters

Custom Order Numbers in Magento 2: Prefixes, Dates & Counters

6 min read 47 views

Can you change the order number format in Magento 2?

Not through the admin: Magento Open Source has no built-in setting for order number format, so changing it means either a developer editing the sales_sequence_* database tables directly — risky on a live store — or a module that adds a format template with prefixes, date variables and counter control. The default numbers are sequential and predictable (000000001, 000000002…), which is both a small information leak and a missed operational win.

This guide covers why the default format is worth changing, what is and is not possible natively, and how to switch safely.

Why default order numbers are a problem

Two reasons, one commercial and one operational:

  • Sequential numbers leak trade information. Anyone who orders twice can estimate your order volume from the gap between their two order numbers — a competitor, a supplier negotiating terms, a marketplace scout. It is a well-known reconnaissance trick precisely because the default makes it free.
  • Generic numbers slow down operations. A number like 000000418 tells nobody anything. A number like AE-2026-000418 tells your bookkeeper which brand and year it belongs to at a glance, makes documents findable in accounts and email threads, and looks considered rather than default on the invoice a B2B customer files.

The operational half compounds when order, invoice, shipment and credit memo each carry unrelated default sequences — matching four documents to one order in a support thread or an accounts query takes longer than it should.

What you can and cannot do natively

Magento stores its document sequences in database tables (sales_sequence_profile, sales_sequence_meta and per-entity sequence tables). A developer working directly in the database can adjust the counter's start point, step and padding, and the profile table does hold prefix and suffix fields — but there is no admin interface to any of it, no date variables, no periodic counter reset, and no per-store-view formats. Hand-editing sequence tables on a live store is also a good way to break order creation entirely: the sequence is consulted on every order placement, and a malformed profile stops checkout.

So the honest native answer is: a developer can nudge the numbers, but formats — prefixes, years, matching document numbers — need code or a module.

What Custom Order Number adds

Our Custom Order Number for Magento 2 module puts the format under Stores → Configuration as a template — prefix, date variables and counter, for example AE-{yyyy}-{counter} — with counter start, increment and padding under your control, an optional periodic counter reset, and per-store-view formats for multi-brand installs. The same scheme can be applied to invoices, shipments and credit memos, so every document for one order shares a recognisable number.

GoalTemplate shapeExample result
Brand prefix onlyAE-{counter}AE-000418
Brand and yearAE-{yyyy}-{counter}AE-2026-000418
Per-store brand, shared schemeDifferent prefix per store viewUK-2026-000418 / EU-2026-000102

A yearly reset paired with a year variable gives you tidy per-year sequences (AE-2026-000001 starts each January) without any risk of two orders ever sharing a number.

Switching safely: a short checklist

  1. Design the template before touching config. Letters, numbers and hyphens only; put the counter last; include a date part if you plan to reset the counter, so numbers can never collide.
  2. Decide the counter start. Starting above your current order count (say 010000 when you have 4,000 orders) avoids any visual overlap with historic numbers — and stops order number one from advertising that you are new.
  3. Apply the same scheme to invoices, shipments and credit memos so documents match across the order's lifecycle.
  4. Test on staging first: place an order, invoice it, ship it, refund it, and check all four documents carry the expected numbers.
  5. Check the downstream systems that consume order numbers — accounting, feeds, warehouse. If your orders flow into Xero, the new format travels with them; see our Magento 2 Xero integration guide for how order data maps across.

Choosing a format that ages well

The formats that cause regret are the clever ones. A few principles from stores that have lived with theirs for years:

  • Keep it short enough to read over the phone. Support conversations start with "what's your order number?" — AE-2026-000418 survives that; a fifteen-character composite does not.
  • Encode only what stays true. A brand prefix and a year never become wrong. Encoding channel, warehouse or product category into the number bakes in today's operations, and the meaning rots when the business changes.
  • Pad the counter for your real volume. Six digits comfortably outlasts most stores; too little padding means an ugly width change mid-year, too much just looks inflated.
  • Change the format rarely. Every switch creates a visual seam in your order history. Design once, deliberately, and leave it alone.

Two things to know before switching

  • Existing orders keep their numbers. The format applies from the change onward; history is untouched, so reports and old invoices stay consistent.
  • Transactional emails carry the new format automatically — the increment ID is a string wherever it appears, so templates need no changes. While you are looking at order emails, it is worth confirming they actually reach the inbox: Magento order emails going to spam covers the deliverability side.

FAQ

Can I change the order number format in Magento 2 without a module?

Not through the admin — Magento Open Source has no setting for it. Developers can alter counters and padding in the sales_sequence_* tables, but formats with prefixes, date parts or per-store variation need code or a module.

Do payment gateways care about the order number format?

Gateways treat the increment ID as an opaque string, so standard prefixes and date parts cause no issues. Keep the format to letters, numbers and hyphens and avoid characters that need escaping in URLs or APIs.

Will changing the format renumber my existing orders?

No — existing orders keep their original numbers and the new format applies only from the change onward. That is the safe behaviour: historic invoices, reports and customer emails all stay consistent with what was issued.

Does it work per store view?

Yes — each store view can carry its own format, which is the clean way to give each brand in a multi-store install its own recognisable numbering. Built against Magento Open Source 2.4.9, running on PHP 8.4 and 8.5.

Custom Order Number is a one-off purchase — no subscription — and is included in the AgenticEcom Suite.