shop:onBeforeOrderRecordCreate event
The shop:onBeforeOrderRecordCreate event is triggered before an 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 user interface. In case if the order is created from the front-end website, this event triggers after the shop:onOrderBeforeCreate. The event handler should accept two parameters - the order object (Shop_Order) and the form session key string.
Event handler example:
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!');
}
}
Next: shop:onBeforeShippingQuote
Previous: shop:onDisplayOrdersPage event
Return to Handling LemonStand events

