Triggered before an order changes its status.
The event allows to cancel the status update. To cancel the update the handler should return FALSE. Event handler example:
public function subscribeEvents()
{
Backend::$events->addEvent('shop:onOrderBeforeStatusChanged', $this, 'before_status_changed');
}
public function before_status_changed($order, $new_status_id, $prev_status_id, $comments, $send_notifications)
{
$status = Shop_OrderStatus::create()->find($new_status_id);
//for orders over $250, set the status to "New big order" instead of "New"
if($status && $status->code == 'new' && $order->subtotal >= 250)
{
$new_status = Shop_OrderStatus::create()->find_by_code('new_big');
if($new_status)
{
Shop_OrderStatusLog::create_record($new_status->id, $order, $comments, $send_notifications);
return false;
}
}
}