Retrieving Tracking Information from Orders

This guide provides developers with the method to retrieve shipment tracking information from WooCommerce orders using Advanced Shipment Tracking (AST). The extracted data can be utilized in various ways, such as integrating with SMS plugins to send tracking updates or exporting tracking information to a CSV file.


The ast_get_tracking_items function is a crucial tool in AST that allows developers to fetch detailed tracking information for any specified order. This function is particularly useful when you need to programmatically access tracking data for custom development needs.

Code Snippet for Retrieving Tracking Information

Below is a PHP code snippet that demonstrates how to use the ast_get_tracking_items function:

// Check if function exist
if ( function_exists( 'ast_get_tracking_items' ) ) {
	$order_id = 123; // Replace with your order_id
	$tracking_items = ast_get_tracking_items($order_id);
	foreach($tracking_items as $tracking_item){		
		$tracking_number = $tracking_item['tracking_number'];
		$tracking_provider = $tracking_item['formatted_tracking_provider'];
		$tracking_url = $tracking_item['formatted_tracking_link'];
		$date_shipped = date_i18n( get_option( 'date_format' ), $tracking_item['date_shipped'] );		
		// Tracking per item info
		$products_list = $tracking_item['products_list'];
		foreach($products_list as $product){
			$product = wc_get_product( $product->product );				
			$qty = $product->qty;	

Implementation Notes

  • Check for Existence: Before using ast_get_tracking_items, always check if the function exists to avoid errors in environments where AST may not be installed or activated.
  • Order ID: Replace the placeholder order ID (123) with the actual ID of the order you’re querying.
  • Handling Data: The snippet retrieves various pieces of tracking information which you can use as needed. This includes the tracking number, provider, URL, and shipment date, as well as detailed product and quantity information for each tracking item.
  • Customization: Modify and extend the snippet according to your specific requirements, whether it’s for sending SMS updates, generating reports, or any other application.

Use Cases

  • SMS Integration: Integrate with SMS plugins to send personalized tracking updates to customers.
  • Data Export: Use the retrieved data to create comprehensive tracking reports or export to CSV files for record-keeping or analysis.

By utilizing this guide and the provided code snippet, developers can effectively access and utilize order tracking information from AST, enhancing the functionality and user experience of their WooCommerce store.


Billed annually

Buy Now