In Drupal, commerce Orders are acted as a separate entity. The order has different status during each stage on purchasing. These status updates are taken place during the order checkout process. It possible us to update order status programmatically from one state to others.
commerce_order_status_update(<order_obj>, <order_status>, TRUE, <log_message>); ORDER_OBJ: Commerce Order Object ORDER_STATUS: Order new status LOG_MESSAGE: Log message on saving. </log_message></order_status></order_obj>
// Updating Order status. $orderObj = commerce_order_load(123456); commerce_order_status_update($orderObj, 'canceled', TRUE, 'Order Voided'); $orderObj->log = 'Order cancelled programatically'; commerce_order_save($orderObj);