I am struggling to get an order to be marked as completed in Drupal 7 Commerce.
Customers will go through the checkout process inside of Drupal, gets marked as "Awaiting shipment" (a custom order status), but then a fulfillment team goes through a different program and the order should be getting updated programmatically as "Completed".
However, when I use
commerce_order_status_update it doesn't seem to want to get marked as completed.
Here is the code I am working with:
$order_entity = commerce_order_load($orderId); commerce_order_status_update($order_entity, 'completed', false, true, 'Order updated via warehouse'); watchdog('warehouse', 'Order status updated %o', array('%o' => $order_entity->status)); //Does not equal 'completed'
I know this code is firing because of two reasons:
- When I set 'completed' to be different status messages, it works
- I see the revision message "Order updated via warehouse", but the status has not changed.
Is there something I have missed? Am I marking the order as completed in a wrong way?
I have also tried EMW
$order_wrapper = entity_metadata_wrapper('commerce_order', commerce_order_load($orderId)); $order_wrapper->status->set('completed'); watchdog('warehouse', 'Order status updated %o', array('%o' => $order_wrapper_status->value())); // Does not update to 'completed' $order_wrapper->save();
I added the watchdog statements that I have used to echo out of the operation was successful.
It should also be noted that there are no Rules modifying the order status at this point. I have gone through my list of Rules and verified that nothing is modifying it, and the order history shows no new revision created from Rules.
Error logs also show no error happening on save process. The operation is successful if I change 'completed' to any other status.