If I want to use this hook in order to execute a code when the order is complete.
function hook_commerce_order_update($order) {
if ($order->status == 'completed') {
// ...
}
}
Is this condition sufficient, or should I add the following in order to prevent the confusion with the complete status that belongs to the checkout state?
if ($order->status != $order->original->status) {
$status = commerce_order_status_load($order->status);
$state = commerce_order_state_load($status['state']);
if (($state['name'] == 'completed') && ($order->status == 'completed')) {
// ...
}
}