Skip to content

Instantly share code, notes, and snippets.

@zorem
Last active April 11, 2022 12:49
Show Gist options
  • Save zorem/60b833b32830d9656c01f88707ce4532 to your computer and use it in GitHub Desktop.
Save zorem/60b833b32830d9656c01f88707ce4532 to your computer and use it in GitHub Desktop.
Below is the code snippet for get formatted tracking info
<?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'] );
// Tracking per item info
$products_list = $tracking_item['products_list'];
foreach($products_list as $product){
$product = wc_get_product( $product->product );
$qty = $product->qty;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment