Problem/Motivation
In D7 the Commerce Billy provided functionality for generating sequential order numbers, allowing for monthly and yearly sequences, custom patterns, etc.
In D8 this functionality is currently provided by the Commerce Order Number module.
However, the module has a number of limitations, requiring it to be re-architected: #2944343: Refactor module architecture (roadmap).
Recently the Centarro team has been working on a port of Commerce Invoice, which also has a requirement for sequential number generation.
So, it makes sense to add this functionality to Commerce, allow it to be used by orders, and allow Commerce Invoice to depend on it.
The code would have to be architected so that it handles both single store and multi store sites properly.
This new functionality would live in a commerce_number_pattern submodule. The architecture would resemble pathauto, with commerce_number_pattern config entities holding the settings, allowing patterns to be configured for orders and invoices, and allowing different order/invoice types to optionally have their own settings.
Comment | File | Size | Author |
---|---|---|---|
#17 | number-pattern-tokens.png | 263.83 KB | bojanz |
#15 | commerce-number-pattern.png | 148.71 KB | bojanz |
#13 | 2730131-number-pattern.patch | 65.14 KB | bojanz |
| |||
#8 | 2730131-number-pattern.patch | 66.39 KB | bojanz |
Comments
Comment #2
Scott Robertson CreditAttribution: Scott Robertson at Acro Commerce commentedWorking on this.
Comment #3
mglamanUnassigning, no work added.
Comment #4
mglamanLooks like we'd just need to merge in https://www.drupal.org/project/commerce_order_number, I think.
Comment #6
bojanz CreditAttribution: bojanz at Centarro commentedUpdating the issue summary. We have a plan, we have initial code (by jsacksick).
The code is currently at https://github.com/jsacksick/commerce_number_pattern
I am going to roll a patch once I'm satisfied with the final shape of the code.
Comment #8
bojanz CreditAttribution: bojanz at Centarro commentedLet's do one last test run.
Crediting Lisa who worked on the number pattern form UX.
Comment #10
bojanz CreditAttribution: bojanz at Centarro commentedCrediting agoradesign for his work on commerce_order_number.
Comment #12
bojanz CreditAttribution: bojanz at Centarro commentedLet's try again, without the duplication test. It only fails on DrupalCI, but I'm in no mood to chase why.
Comment #13
bojanz CreditAttribution: bojanz at Centarro commentedComment #15
bojanz CreditAttribution: bojanz at Centarro commentedCommitted. Attaching screenshot.
Followups:
#3080229: Update commerce_order to use commerce_number_pattern
#3080247: [Number pattern] Rework the pattern tokens, replace {number} with a real token
#3080238: Allow sequential numbers to be reset from the UI
Comment #16
agoradesign CreditAttribution: agoradesign commentedNice! :-)
Comment #17
bojanz CreditAttribution: bojanz at Centarro commentedNow that #3080247: [Number pattern] Rework the pattern tokens, replace {number} with a real token has landed, attaching an updated screenshot :)
Comment #18
danrodI just applied this patch on a Drupal 8.6 site with Commerce 8.x-2.13 enabled. When I try to add a new number pattern at
admin/commerce/config/number-patterns/add
I get this Fatal Error:After doing a bit of research, I see that ConfigurableInterface is not present in 8.6, sadly, we need to stay on Drupal core 8.6 because of infrastructure limitations, that leaves me the choice of refactoring a bit this patch for 8.6 compatibility, or perhaps do the jump to 8.7.
Comment #20
Jeff Veit CreditAttribution: Jeff Veit commentedDanrod, for most use cases, it looks like ConfigurablePluginInterface is a drop-in replacement for ConfigurableInterface. That means that you can probably just delete the 'Plugin' part in two lines, and it will work.