Docs Advanced Shipment Tracking Pro (AST PRO) Retrieving Tracking Information from Orders

Retrieving Tracking Information from Orders

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

ParameterTypeDescription
$order_idintThe WooCommerce order ID to retrieve tracking for.
Return valuearrayArray of tracking entry arrays. Empty array if no tracking is recorded.

Tracking entry fields

KeyTypeDescription
tracking_numberstringThe raw tracking number.
formatted_tracking_providerstringThe carrier display name.
formatted_tracking_linkstringThe full tracking URL.
date_shippedintUnix timestamp of the shipped date.
products_listarrayArray 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_list is 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->qty from the raw product object in products_list — not from the WC_Product returned by wc_get_product(), which does not have a qty property.

Related: Adding Tracking Info to Orders