The ast_get_tracking_items() function returns all tracking entries for a given order. Use it to read tracking data programmatically — for example, to pass tracking info to an SMS plugin, export it to a CSV, or integrate with a third-party system.
Function reference
| Parameter | Type | Description |
|---|---|---|
$order_id | int | The WooCommerce order ID to retrieve tracking for. |
| Return value | array | Array of tracking entry arrays. Empty array if no tracking is recorded. |
Tracking entry fields
| Key | Type | Description |
|---|---|---|
tracking_number | string | The raw tracking number. |
formatted_tracking_provider | string | The carrier display name. |
formatted_tracking_link | string | The full tracking URL. |
date_shipped | int | Unix timestamp of the shipped date. |
products_list | array | Array of product objects for per-item tracking entries. Each object has a product property (the product ID) and a qty property (the quantity in this shipment). |
Code snippet
product; // WooCommerce product ID
$qty = $item->qty; // Quantity in this shipment
$product = wc_get_product( $product_id );
if ( $product ) {
$product_name = $product->get_name();
}
}
}
}
}
Notes
- Always wrap the call in
function_exists( 'ast_get_tracking_items' )so the code fails gracefully when AST PRO is not active. products_listis populated only when Tracking Per Item is enabled in General Settings and the tracking entry was added with SKU/quantity data. It is empty for standard (non-per-item) tracking.- Read
$item->qtyfrom the raw product object inproducts_list— not from theWC_Productreturned bywc_get_product(), which does not have aqtyproperty.
Related: Adding Tracking Info to Orders