Adding tracking info to orders

This article provides developer documentation for adding support with the Advanced Shipment Tracking for WooCommerce.

AST provides a way for shipping services and plugin to add shipment tracking information to the WooCommerce order meta data and to fulfill the orders. You can add the shipment tracking information to orders programmatically or, use the shipment tracking endpoint in WooCommerce API.

Shipment Tracking order meta reference

order_idstringUnique identifier for orderRequired
tracking_providerstringTracking provider nameRequired
tracking_numberstringTracking numberRequired
date_shippeddateDate when the package was shipped – default to the date/time that the tracking was added via the APIOptional
status_shippedint0 – do not change the order status, 1 – change order status to “Shipped” (completed), 2 – change the order status to custom status “Partially Shipped” (Defaults to 0).Optional

Add Shipment tracking

With the use of this code snippet, you can add shipment tracking information to the order.

// Check if AST PRO plugin is Installed
if ( class_exists( 'WC_Advanced_Shipment_Tracking_Actions' ) ) {
	$order_id = '123';
	$tracking_provider = 'USPS';
	$tracking_number = '123123';
	$date_shipped = '2022-04-21';
	$status_shipped = 1;	
	if ( function_exists( 'ast_insert_tracking_number' ) ) {
		ast_insert_tracking_number( $order_id, $tracking_number, $tracking_provider, $date_shipped, $status_shipped );