I was looking for a solution for a long time how to number orders in drupal commerce not sequential(1,2,3,4,....), but to assign an order number corresponding to the unix timestamp date.
Someone advised to do it through the rules, but it turned out to be difficult for me.
Found a solution on how to change the numbering scheme via the hook:
<?Php
/**
 * Implements hook_commerce_order_presave().
 *
 * Alter order number.
 * $order doesn’t have 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);
  }
}
?>

This approach works, but it multiplies the current number by 63.How can I correct it so that the order number is assigned to the timestamp?

2 Answers 2

$order->order_number=time();
Thank you) it works ..
Maybe someone knows how to change the order number and its ID in the same way? I guess that you need to use another hook ..And is it even possible to change the ID?