LemonStand Documentation

shop:onExtendOrderItemModel event

The shop:onExtendOrderItemModel event allows to add new columns to the order item model. Before you add columns to the model, your module should add corresponding columns to the database (the shop_order_items table). You can learn about updating the database structure from the Creating and updating database tables article. You can find examples of extending the order item model in this article.

The event handler should accept a single parameter - the order item object (Shop_OrderItem class). Example:

public function subscribeEvents()
{
  Backend::$events->addEvent('shop:onExtendOrderItemModel', $this, 'extend_order_item_model');
  Backend::$events->addEvent('shop:onExtendOrderItemForm', $this, 'extend_order_item_form');
}
 
public function extend_order_item_model($order_item)
{
  $order_item->define_column('x_subscription_start_date', 'Start date')->invisible();
  $order_item->define_column('x_subscription_end_date', 'End date')->invisible();
}

public function extend_order_item_form($order_item)
{
  $order_item->add_form_field('x_subscription_start_date', 'left')->tab('Subscription');
  $order_item->add_form_field('x_subscription_end_date', 'right')->tab('Subscription');
}

Next: shop:onExtendOrderItemForm event
Previous: shop:onGetCartItemPrice event
Return to Handling LemonStand events