Merx

Order number

Merx creates a sequential number for each order page by default. If you want to create your own order numbers you can do so via the config file.

Use the orderNumber option to create your own logic for order numbers. The first argument of the function is of type OrderPage.

/site/config/config.php
return [
    'wagnerwagner.merx.orderNumber' => function (OrderPage $virtualOrderPage): int
    {
        $lastOrder = $virtualOrderPage->siblings()->listed()->last();
        return ($lastOrder?->orderNumber()->toInt() ?? 0) + 1;
    },
];

Merx calls the function for one order at a time, and order pages sort in the order they were created. So the last listed sibling is always the newest order, even when two customers check out at the same moment.

Since each number counts on from the newest order, removing that order from the file system — a test order, say — hands its number out again.