Get tracking info from orders

Below is the code snippet for getting shipment tracking information into of order using AST for any particular order. Also if you want to add tracking information into order SMS with any SMS plugin you can use this code to get tracking information and add it. Also, users can use the below code to export tracking data to a CSV file.

<?php
// 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'] );									
	}
}

Free

Download