shop:onOrderBeforeStatusChanged event
The shop:onOrderBeforeStatusChanged event is triggered before an order changes its status. The event handler should accept 5 parameters: the order object (Shop_Order), the new status identifier, the identifier of the previous order status, the comments string and a boolean determining whether or not to send email notification for the status change.
If the event handler returns false, the status change will be prevented.
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;
}
}
}Next: shop:onOrderStatusChanged event
Previous: shop:onExtendOrderInvoicesToolbar event
Return to Handling LemonStand events

