WPCargo FREE track result template can be customize using theme. Note: If you have Custom Field add on installed see this related documentation.

The following steps on how to customize the track result template
- Create new directory under your current theme “wpcargo“
- Create the following files under “wpcargo” directory
- result-form-header-details.tpl.php – Header section
- result-form-shipper-details.tpl.php – Shipper and Receiver Section
- result-form-shipment-details.tpl.php – Shipment Section
- result-shipment-history.tpl.php – Shipment History Section

Track Result Sections

Remove Header Details
add_action('init', 'remove_action_callback');
function remove_action_callback(){
global $wpcargo_track_form;
remove_action('wpcargo_track_header_details', array( $wpcargo_track_form, 'wpcargo_trackform_result_header_details_template' ), 10, 1 );
}

Remove Status in Track Result
add_action('init', 'remove_action_status_hook_callback');
function remove_action_status_hook_callback(){
remove_action( 'wpcargo_before_shipment_details', 'wpcargo_track_shipment_status_result', 10, 1 );
}

Remove Packages
add_action('init', 'remove_wpcargo_after_package_details_callback');
function remove_wpcargo_after_package_details_callback(){
remove_action('wpcargo_after_package_details', 'wpcargo_multiple_package_after_track_details', 5, 1 );
}

Remove Total Weight Info
add_action('init', 'remove_wpcargo_after_package_totals_callback');
function remove_wpcargo_after_package_totals_callback(){
remove_action('wpcargo_after_package_totals', 'wpcargo_after_package_details_callback', 10, 1 );
}
[php]
<h2 style="margin-top: 100px;">Filter Labels</h2>
<div class="knowledgebase-screenshot"><img src="https://www.wpcargo.com/wp-content/uploads/2021/07/track-result-tracking-number.png" alt=""/></div>
<h3>Filter the Tracking Number</h3>
[php]
add_filter( 'wpcargo_track_result_shipment_number', 'wpcargo_track_result_shipment_number_callback' );
function wpcargo_track_result_shipment_number_callback( $tracknumber ){
echo "Insert Text Before Tracking Number ".$tracknumber;
}

Change Ther Shipper and Receiver Header
Shipper Header
add_filter('result_shipper_address', 'custom_result_shipper_address_callback');
function custom_result_shipper_address_callback( $shipper_label ){
$shipper_header = 'Customer Shipper Label';
return $shipper_header;
}
Receiver Header
add_filter('result_receiver_address', 'custom_result_receiver_address_callback');
function custom_result_receiver_address_callback( $receiver_label ){
$receiver_label = 'Customer Shipper Label';
return $receiver_label;
}

Change History Label
add_filter('wpc_shipment_history_header', 'custom_wpc_shipment_history_header_callback');
function custom_wpc_shipment_history_header_callback( $history_header ){
$history_header = 'Customer History Label';
return $history_header;
}
Sample code to remove track form result section on client side:
add_action('init', 'remove_action_on_client_side_callback');
function remove_action_on_client_side_callback(){
global $wpcargo_track_form;
$current_user = wp_get_current_user();
/*
* WPCargo Roles
*
* wpcargo_client
* wpcargo_pending_client
* wpcargo_employee
* cargo_agent
*/
/*
* Remove the Menu for WPCargo Client only
*/
if( in_array( 'wpcargo_client', $current_user->roles ) ){
remove_action('wpcargo_track_header_details', array( $wpcargo_track_form, 'wpcargo_trackform_result_header_details_template' ), 10, 1 );
}
}