LemonStand Documentation

shop:onExtendOrderModel event

This event allows you to define new fields in the order model. The event handler should accept two parameters - the order object (Shop_Order) and the form execution context string. To add new columns to the order model, please call the define_column() method of the order object. Before you add new columns, you should add them to the database (the shop_orders table). Please read the Extending existing models article to learn more about extending the order model.

Example of the event handler:

public function subscribeEvents()
{
  Backend::$events->addEvent('shop:onExtendOrderModel', $this, 'extend_order_model');
  Backend::$events->addEvent('shop:onExtendOrderForm', $this, 'extend_order_form');
}
 
public function extend_order_model($order, $context)
{
  $order->define_column('x_extra_description', 'Extra description');
}
 
public function extend_order_form($order, $context)
{
  $order->add_form_field('x_extra_description')->tab('Billing Information');
}

Next: shop:onExtendOrderForm event
Previous: shop:onExtendManufacturerForm event
Return to Handling LemonStand events