order_number not increasing, despite number pattern config change

Created on 30 March 2022, over 2 years ago
Updated 2 December 2024, 20 days ago

Problem

With an existing set of products and a default number pattern configuration (infinite, default start index), orders receive incrementing numbers. When changing the number pattern for the default configuration, there is no update to the respective row in `commerce_number_pattern_sequence`-Table happening. The change does not apply when commerce core triggers its workflow and tries to run the sequence. The erroneous part checks if there is a repeating pattern or if the sequence returns false, it aborts and skips the generation of the pattern and the replacement of the actual order_number with an increased order_number.

All this happens inside `SequentialNumberPatternBase`: The `generate()` method gets called > `getNextSequence()` gets called with the current order. At this point the current sequence gets fetched and only if it returns falsy or if it should reset (yearly/monthly), the number gets changed. I stopped there with further research aside from watching above mentioned table not getting updated.

Fix Commerce > Configuration > Orders > Number Pattern > Define new Pattern with "Infinite" and set "Initial number" to some random (easily recognizable) number

Reproduce

  1. Admin UI Commerce > Configuration > Orders > Number Pattern
  2. Redefine existing Pattern with "Infinite" and set "Initial number" to some random (easily recognizable) number
  3. Generate a new order
  4. Place the order (this is when the NumberPattern gets generated and injected into the WorkFlow)

Proposed solution

  1. Change the field display to non-editable fields.
  2. Add a `updated` column to the `commerce_number_pattern_sequence` table

This way, everyone understands that number patterns are not meant to get changed. And when you connect an ERP, CRM or some marketing service, you don't face the problem that connecting and mapping purchases aims at a moving target. Having a from-to timespan for every number pattern, you have a better log for the usage. Bonus points for adding a serialized log column that keeps track of the connected entities and their ID.

🐛 Bug report
Status

Active

Version

2.29

Component

Commerce

Created by

🇦🇹Austria fjk

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.

  • 🇩🇪Germany Anybody Porta Westfalica

    I can confirm this! Once the first order has been created, changing the number doesn't do anything. That's definitely unexpected, at least without description and disabled input field!

  • 🇮🇱Israel jsacksick

    Well, this is why it is called "initialNumber"? it is not disabled because this only becomes a problem once an order is placed.
    This isn't really a bug, we probably should disable the field. But there is also a separate form for resetting the sequence.

    I guess as a UX improvement, we can disable the initial number field.

  • 🇩🇪Germany Anybody Porta Westfalica
Production build 0.71.5 2024