What can we help you with?

Get DHL Tracking Numbers for WooCommerce Order IDs (Code Snippet)

By default, the ELEX WooCommerce DHl Shipping Plugin shows tracking status in a pop-up window. If you wish to display DHL tracking numbers in desired pages of your website, you can follow the steps mentioned in this article.

This code snippet will only for ELEX WooCommerce DHL Shipping Plugin.

Code snippet to get DHL Tracking Numbers

Step 1: Add the following code snippet at the end of the functions.php file of your activate website theme.

/*Shortcode to get DHL tracking numbers (AirWay Bill Numbers) for provided WooCommerce Order id */
add_shortcode('ELEX_DHL_TRACK_INFO', 'get_tracking_numbers_express_dhl_elex');

function get_tracking_numbers_express_dhl_elex($attributes){

$airway_bill_numbers = get_post_meta($attributes['order_id'], 'archive_reference_data_dhl_elex', true);
$tracking_number = '';
$tracking_number = $airway_bill_numbers['airway bill number'];
return $tracking_number;

Step 2: Use the shortcode [ELEX_DHL_TRACK_INFO order_id=”{woocommerce order id}”] in any of the desired pages to display the tracking status. You should replace {woocommerce order id} with your desired order ID.

Let us understand this with a simple demonstration.

We can add the shortcode [ELEX_DHL_TRACK_INFO order_id=”4491″] in the My-Accounts page, as shown in the screenshot below.

DHL Tracking Number with WooCommerce Order IDs | Short-Code added
Short-Code added in the My-Accounts page

You can customize how the tracking number has to be displayed as you like. Once you save the settings of the page, you can move to the My-Accounts page to see the DHL Tracking Number, as shown in the sample screenshot below.

DHL Tracking Number with WooCommerce Order IDs | Tracking Number Displayed
Tracking Number Displayed in the My-Accounts page


In this way, you can the tracking number in any of the desired page(s).

To explore more details about the plugins, go check out ELEX WooCommerce DHL Express / eCommerce / Paket Shipping Plugin with Print Label.

Read the article for setting up DHL Express understand the plugin, in detail. Or check out the product documentation section for more related articles.

You can also check out other WooCommerce and WordPress plugins in ELEX.

Previous Show Customer Selected Shipping Service in DHL Shipping Label (Code Snippet)
Next Hide Shipping Cost on the DHL Shipping labels and Commercial Invoices (Code Snippet)
You must be logged in to post a comment.