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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman created an issue. See original summary.

Scott Robertson’s picture

Assigned: Unassigned » Scott Robertson

Working on this.

mglaman’s picture

Assigned: Scott Robertson » Unassigned

Unassigning, no work added.

mglaman’s picture

Looks like we'd just need to merge in https://www.drupal.org/project/commerce_order_number, I think.

bojanz credited jsacksick.

bojanz’s picture

Title: Provide an order type setting for order number generation » Add a commerce_number_pattern submodule for sequential (order/invoice) number generation
Issue summary: View changes

Updating 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.

bojanz’s picture

Status: Active » Needs review
FileSize
66.39 KB

Let's do one last test run.

Crediting Lisa who worked on the number pattern form UX.

bojanz’s picture

Crediting agoradesign for his work on commerce_order_number.

Status: Needs review » Needs work

The last submitted patch, 8: 2730131-number-pattern.patch, failed testing. View results

bojanz’s picture

Status: Needs work » Needs review

Let's try again, without the duplication test. It only fails on DrupalCI, but I'm in no mood to chase why.

bojanz’s picture

  • bojanz committed cbb51af on 8.x-2.x authored by jsacksick
    Issue #2730131 by bojanz, jsacksick, lisastreeter, agoradesign: Add a...
bojanz’s picture

agoradesign’s picture

Nice! :-)

bojanz’s picture

FileSize
263.83 KB
danrod’s picture

I 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:

Fatal error: Interface 'Drupal\Component\Plugin\ConfigurableInterface' not found in /var/www/html/modules/contrib/commerce/modules/number_pattern/src/Plugin/Commerce/NumberPattern/NumberPatternInterface.php on line 14

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Jeff Veit’s picture

Danrod, 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.