Allows to define new columns in the order item model.
The event handler should accept two parameters - the order item object and the form
execution context string. To add new columns to the order item model, call the
define_column()
method of the item object. Before you add new columns to the model, you should add them to the
database (the
shop_order_items table).
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');
}