I know it is a bit late, but here is what I did to modify the line items on an order view.
For my example, I wanted the type field to be displayed, so I altered the view of the commerce_line_item
entity using hook_views_pre_view(&$view)
. Here the code that have:
switch ($view->name) {
case 'commerce_line_item_table':
$view->display['default']->handler->options['fields']['type']['exclude'] = FALSE;
This is all I needed to do since type was already there in the commerce_line_item_table
view defined in commerce_line_item.views_default.inc, but if you want to add a field to the view, it would look something like this
$view->display['default']->handler->options['fields']['type']['id'] = 'type';
$view->display['default']->handler->options['fields']['type']['table'] = 'commerce_line_item';
$view->display['default']->handler->options['fields']['type']['field'] = 'type';
$view->display['default']->handler->options['fields']['type']['relationship'] = 'commerce_line_items_line_item_id';
Please note, that when you later the view for the user/%user/orders/%commerce_order page, it also alters admin/commerce/orders/%commerce_order/view since they both use entity_view