Remove texts from tracking events
This code snippet can be used to remove specific text in the tracking events shown on the tracking page. This is useful for store owners who may want to hide certain information, such as the location of origin, from their customers.

Code Snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'trackship_tracking_event', 'remove_text_tracking_event', 10, 1 ); | |
/** | |
* Remove specified text in the tracking event. | |
* | |
* @param string $tracking_event The tracking event | |
* | |
* @return string The modified tracking event | |
*/ | |
function remove_text_tracking_event ( $tracking_event ) { | |
// Add words to be removed in the $remove array | |
$remove = array( | |
"China", | |
); | |
$tracking_event = str_replace( $remove, '', $tracking_event ); | |
return $tracking_event; | |
} |

Instructions
- To remove multiple words, add additional elements to the $remove array.
- To use this code snippet in WordPress, you can add it to your theme’s functions.php file or use a plugin such as Code Snippets to add it to your site.
- Make sure you have the TrackShip plugin for WooCommerce installed and activated on your site before using this code snippet.
Note: It is recommended to create a backup of your website before making any modifications to your code.