Skip to content

Instantly share code, notes, and snippets.

@xadapter
Last active September 19, 2019 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xadapter/9fa56cff0857bcb71b7bd49d2101cacd to your computer and use it in GitHub Desktop.
Save xadapter/9fa56cff0857bcb71b7bd49d2101cacd to your computer and use it in GitHub Desktop.
Snippet to display WooCommerce Shipment Tracking last live status on WooCommerce->Order page. Display only for UPS, USPS and FedEx. WooCommerce Shipment Tracking Pro - https://www.pluginhive.com/product/woocommerce-shipment-tracking-pro/
/**
* Snippet to display last live tracking status on woocommerce->Order page. Display only for UPS, USPS and FedEx.
* Created at : 20 July 2018
* Updated at : 20 July 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/9fa56cff0857bcb71b7bd49d2101cacd
*/
// Add columns to the order list
add_filter( 'manage_edit-shop_order_columns', function($columns) {
$new_columns = array();
foreach ( $columns as $column_name => $column_info ) {
$new_columns[ $column_name ] = $column_info;
if ( 'shipping_address' == $column_name ) {
$new_columns['ph_tracking_status'] = __( 'Tracking Status' );
}
}
return $new_columns;
} );
// Add data for the added columns
add_action( 'manage_shop_order_posts_custom_column', function( $column ) {
global $post;
if ( 'ph_tracking_status' == $column ) {
$data = get_post_meta( $post->ID, 'wf_wc_shipment_result', true);
if( !empty($data['tracking_info_api']) && is_array($data['tracking_info_api']) ) {
foreach( $data['tracking_info_api'] as $details ) {
if( ! empty($details['api_tracking_status']) )
echo $details['api_tracking_status'].'<br/>';
}
}
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment