Allow number pattern sequences to be reset via the UI

Created on 21 July 2020, almost 5 years ago
Updated 21 March 2025, about 1 month ago

To start:

  1. Create a new "infinite" number pattern, with initial number 1.

A workflow we've gotten used to in Other Ecommerce Software is to start the order numbers at 1 during site build out and then, when the site is ready to go live, reset the order number to 1000 to symbolize "live orders". This doesn't work with Commerce's number patterns, though, as the "initial number" is only ever used to seed the commerce_number_pattern_sequence table. After that number has been seeded, the "initial number" configuration is never looked at again. Even if all the orders created using that number pattern are deleted, the value stored in commerce_number_pattern_sequence remains unchanged.

So, say, we have a number pattern with an initial number of 1, and 3 orders come in. Those orders are numbered 1, 2, and 3. We now want the next order number to be 1000. If we manually UPDATE commerce_number_pattern_sequence SET number = 999 WHERE entity_id = 'example', then our workflow works... the next order number that comes in will be 1000. Alternatively, we could edit our number pattern to change the initial number to 1000, then run DELETE FROM commerce_number_pattern_sequence WHERE entity_id = 'example' and that, too, would work; the next order number would be 1000.

The feature request then boils down to one of:

  1. Provide a "Force reset sequence" button somewhere on the number pattern page. This would simulate the DELETE above.
  2. Or, provide an "Update sequence to" field somewhere on the number pattern page. This would simulate the UPDATE above.

We do want this sequence fiddling to be user-decided; we can't just "automatically force update the sequence" whenever the number pattern is saved. Consider our "infinite" number pattern above: if we start at initial number 1, and three orders come in (numbered 1, 2, 3), and someone then edits the number pattern WITHOUT changing the initial number of 1, then the sequence would be force updated back down to 1 (or NULL) and the next order would again be numbered 1, causing unwanted (for "infinite") duplicates.

Feature request
Status

Active

Version

2.0

Component

Number pattern

Created by

🇺🇸United States morbus iff

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024