Show “Shipment Tracking” in orders history
⚠️ This feature requires the PRO version of Phone Orders for WooCommerce.
Overview
The Orders History panel in Phone Orders PRO shows a table of the selected customer’s previous orders. By default it displays columns like order number, date, status, and total. This snippet adds a Shipment Tracking column to that table, pulling tracking data directly from the WooCommerce Shipment Tracking plugin — giving agents shipment status at a glance without leaving the Phone Orders screen.
Code Sample
Add the following snippet to your child theme’s functions.php or the Code Snippets plugin:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
add_filter( 'wpo_order_history_customer_table_headers', function($headers) { $new_headers = array(); foreach($headers as $header) { $new_headers[] = $header; if ( $header['key'] == 'status') $new_headers[] = array( 'key'=>'shipment_tracking', 'label'=>'Shipment Tracking', 'escape'=>false); } return $new_headers ; }); add_filter('wpo_order_history_customer_table_row', function($data,$order) { if( class_exists('WC_Shipment_Tracking_Actions') ) $data['shipment_tracking'] = WC_Shipment_Tracking_Actions::get_instance()->get_shipment_tracking_column( $order->get_id() ); return $data; },10,2); |
Code Explained (for Developers)
| Element | Description |
|---|---|
wpo_order_history_customer_table_headers | A Phone Orders PRO filter that controls the column definitions for the customer orders history table. Each column entry needs a key (used to match data rows), a label (displayed as the column heading), and an escape flag. Setting escape to false tells Phone Orders to render the column’s HTML value unescaped — required here because the tracking output contains links and formatted HTML. |
Insertion after 'status' | The snippet loops all existing headers and inserts the new tracking column immediately after the Status column, keeping the table layout logical for agents. |
wpo_order_history_customer_table_row | A Phone Orders PRO filter that populates the data values for each row in the history table. The $data array uses the same column keys defined in the headers filter. |
class_exists( 'WC_Shipment_Tracking_Actions' ) | Safety check confirming WooCommerce Shipment Tracking is active. If it’s absent the column header still appears but the data cell returns empty rather than throwing an error. |
WC_Shipment_Tracking_Actions::get_instance()->get_shipment_tracking_column( $order->get_id() ) | Calls WooCommerce Shipment Tracking’s own method that returns the formatted tracking HTML for a given order ID — the same output you’d see in the WooCommerce admin order list. |
How to Apply This Code
- Open Appearance → Theme File Editor or the Code Snippets plugin.
- Paste the full snippet into your child theme’s
functions.phpor create a new dedicated snippet. - Save and open Phone Orders PRO.
- Select a customer with past orders that have shipment tracking entries.
- Open the Orders History panel and verify the Shipment Tracking column appears next to the Status column with the correct tracking links.
⚠️ Always use a child theme or Code Snippets — parent theme files get overwritten on theme updates.
When Should You Use This?
This snippet suits any store that uses WooCommerce Shipment Tracking and wants agents to quickly confirm dispatch status or share tracking links with customers during a phone call — without switching between Phone Orders and the WooCommerce orders list.