Reputation: 301
In the Woocommerce Shipment Tracking plugin they use:
<?php echo esc_html( $tracking_item['tracking_number'] ); ?>
to get the shipping tracking number. How can use something similar directly in a Woocommerce email template?
Upvotes: 2
Views: 1721
Reputation: 195
Updated version for WooCommerce 3.0+:
$order = new WC_Order( $queue_item->order_id );
$tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
if ( count( $tracking_items ) > 0 ) {
foreach ( $tracking_items as $tracking_item ) {
$tracker = esc_html( $tracking_item['tracking_number'] );
}
}
Upvotes: 1
Reputation: 301
Here is what I came up with and it works!
<?php
$order_id = $order->get_order_number();
$tracking_items = get_post_meta( $order_id, '_wc_shipment_tracking_items', true );
foreach ( $tracking_items as $tracking_item ){
echo esc_html( $tracking_item['tracking_number'] );
}?>
Upvotes: 1