Skip to content

Instantly share code, notes, and snippets.

@zorem
Last active September 13, 2021 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zorem/53ebf4fdeb11f528a6ccfb0c62492cac to your computer and use it in GitHub Desktop.
Save zorem/53ebf4fdeb11f528a6ccfb0c62492cac to your computer and use it in GitHub Desktop.
Endpoint – Create a shipment tracking per item using REST API
//With this endpoint you can add new tracking info to orders:
POST /wp-json/wc-ast-pro/v3/orders/<order_id>/shipment-trackings/
curl -X POST https://your-domain.com/wp-json/wc-ast-pro/v3/orders/<order_id>/shipment-trackings
-u consumer_key:consumer_secret
-H "Content-Type: application/json"
-d '{
"tracking_provider": "USPS",
"tracking_number": "123456",
"date_shipped": "2020-01-24",//date_shipped is optional parameter
"status_shipped": 1,//status_shipped is optional parameter
"sku": t-shirt,blue-jeans //the line item (product) SKU
"qty": 1,1 //the line item (product) quantity
}'
curl -X POST https://your-domain.com/wp-json/wc-ast-pro/v1/orders/<order_id>/shipment-trackings
-u consumer_key:consumer_secret
-H "Content-Type: application/json"
-d '{
"tracking_provider": "USPS",
"tracking_number": "456879",
"date_shipped": "2020-01-24",//date_shipped is optional parameter
"status_shipped": 1,//status_shipped is optional parameter
"sku": t-shirt,blue-jeans //the line item (product) SKU
"qty": 1,2 //the line item (product) quantity
}'
@AbePerl1
Copy link

This API does not work correctly,
First, it does not update the tracking in line, the same way as you with the widget in word press,
It picks up Sku from the parent rather than from the variation item line
When calling Get Shipment, it does not say which sku was shipped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment