Answer the question
In order to leave comments, you need to log in
How to make the numbering of orders in drupal commerce not serial (1,2,3,4,....), but assign the order number corresponding to the unix timestamp date?
For a long time I was looking for a solution on how to make order numbering in drupal commerce not serial (1,2,3,4,....), but assign an order number corresponding to the unix timestamp date.
Someone advised to do it through rules, but it turned out to be difficult for me.
I found a solution how to change the numbering scheme through a hook:
<?php
/**
* Implements hook_commerce_order_presave().
*
* Alter order number.
* $order does not need to be referenced since it is an object.
*/
function yourmodule_commerce_order_presave($order) {
if (isset($order->order_id)) {
// Alter order number by multplying the order id with 63.
$order->order_number = sprintf('%08d', $order->order_id * 63);
}
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question