How to change order_number on hook_commerce_payment_order_paid_in_full or hook_commerce_checkout_complete I'm trying to change the order_number after the order has been created.  Specifically, I need to do this in the hook_commerce_checkout_complete or hook_commerce_payment_order_paid_in_full functions.

I'm sending orders out for 3rd party fulfillment and want to store the 3rd party's unique order_number (which is different than Drupal Commerce's order_number) into DC's order_number column.

I do not need to change the order_number in hook_commerce_order_presave because this happens before I make the call to 3rd party fulfillment when the new order_number gets generated in their system.

You can see in the code below that this is being executed as the order is paid in full, during checkout completion.  In this example the order_number 00001890 is trying to be changed to 9999999 and saved, but the new order_number is not actually saving.

function custom_module_commerce_payment_order_paid_in_full($transaction) {
  print "&lt;pre&gt;";
  print "paid in full\n";
  print_r($transaction);

  $orderid = $transaction-&gt;order_id;
  $order = commerce_order_load($orderid);

  print "BEFORE CHANGING ORDER NUMBER \n";
  //order number is 00001890
  print_r($order);

  $order-&gt;order_number = 9999999;

  print "AFTER CHANGING ORDER NUMBER \n";
  //order number is 9999999
  print_r($order);

  $result = commerce_order_save($order);

  print "Order save result\n";
  //SAVED_UPDATED = 2
  print_r($result);

  print "DID ORDER NUMBER CHANGE??? \n";
  //no, it did not change, it's still 00001890
  print_r($order);

  $order = commerce_order_load($orderid);
  //confirm order number did not change, it's still 00001890
  print_r($order);

  print "&lt;/pre&gt;";
  die();
}


Any help or advice would be much appreciated!
I don't think it's a good idea to change the order id. 

I would rather goto admin/commerce/config/order/fields and a new number field which will be used to store the 3rd party's order id in the field.

That way you are not changing the default workflow of Drupal commerce and it will also be easier for you to compare your order id against the third party order id if something goes wrong.