Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Order
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
26 Oct 2017 at 00:46 UTC
Updated:
6 Sep 2018 at 09:22 UTC
Jump to comment: Most recent
Comments
Comment #2
ryross commentedMy client sets the order number after the order has been placed because they have a manufacturing facility that depends on sequential order numbers. So we have a Cart ID (visible to the users) and Order IDs (visible to the user after they order has been placed. So changing how the order number is set would negatively affect us.
Comment #3
mglamanIf we could get #2730131: Add a commerce_number_pattern submodule for sequential (order/invoice) number generation to land it would be interesting to support draft + placed order numbers.
Comment #4
bojanz commentedAn order number is by definition the number of a placed order. It can never be set before that.
Order numbers follow a specific pattern and need to be sequential. Generating them when the cart is created would create holes in the numbers, since each cart would get its own number. That means that it would be no better than the order ID.
Gateways should send the order ID, or nothing. Otherwise their support should be contacted for clarification ("Which number to send if the order is being prepaid at checkout, meaning that there is no invoice number yet")
Comment #6
_dcre_ commented@bojanz
you wrote the following
Order numbers follow a specific pattern and need to be sequential. Generating them when the cart is created would create holes in the numbers, since each cart would get its own number. That means that it would be no better than the order ID.
however, looking at the code we see that the order number is only set once, according to the following
/**
* Sets the order number, if not already set explicitly, to the order ID.
*
* @param \Drupal\state_machine\Event\WorkflowTransitionEvent $event
* The transition event.
*/
public function setOrderNumber(WorkflowTransitionEvent $event) {
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $event->getEntity();
if (!$order->getOrderNumber()) {
$order->setOrderNumber($order->id());
}
}
The above event is triggered when an the commerce_order.place.pre_transition.
So it looks like order number do have holes, as it is indeed the order id.
Am i missing something here?