Vote up!
Vote down!

How to add subheading in Orders Page

In the url, user/%user/orders/%commerce_order (or user/1/orders/1) also known as the order details page, how can I add a subheading? All I know is how to change the title (implement hook_menu_alter, change the title callback, etc). But I'm having trouble figuring out how to add a subheading in the page. I tried tracing the code and figure out how the page is generated but I can't figure it out. How is the page generated or what hook/s should I implement to achieve this?

Asked by: akosipax
on February 26, 2013

1 Answer

Vote up!
Vote down!

I just used hook_page_alter.

<?php if(isset($page['content']['system_main']['commerce_order'])){
$order_id = key($page['content']['system_main']['commerce_order']);
$timestamp = intval($page['content']['system_main']['commerce_order'][$order_id]['#entity']->created);
$created = date('F j, Y - g:ia',$timestamp);
//Add subheading
$page['content']['system_main']['commerce_order'][$order_id]['subheading'] = array(
'#weight' => -20,
'#markup' => '<h3>Order #'.$order_id.', '.$created.'</h3>',
//Add print icon
$page['content']['system_main']['commerce_order'][$order_id]['print_icon'] = array(
'#weight' => -15,
'#markup' => '<div id="print">Print This Page</div>',
Answer by: akosipax
Posted: Mar 8, 2013