Triggered before a new order record is saved to the database.
Unlike the
shop:onOrderBeforeCreate event, this event is triggered even if the order is created
from the Administration Area. In case if the order is created from the front-end website,
this event triggers after the
shop:onOrderBeforeCreate.
public function subscribeEvents()
{
Backend::$events->addEvent('shop:onBeforeOrderRecordCreate', $this, 'process_new_order_record');
}
public function process_new_order_record($order, $session_key)
{
// Load the item list
$items = $order->list_related_records_deferred('items', $deferred_session_key);
// Perform some check
foreach ($items as $item)
{
if ($item->quantity > 10)
throw new Phpr_ApplicationException('Error!');
}
}