What can we help you with?

Show Customer Selected Shipping Service in DHL Shipping Label (Code Snippet)

Barry has a WooCommerce store in which he makes use of ELEX WooCommerce DHL Shipping Plugin to access DHL rates and services. He offers a Flat-rate service in the front-end of the store with a nominal charge but uses DHL service to print labels and process shipments. His requirement was that the Flat rate is printed on the shipping label, instead of the DHL service name and rate to avoid confusion in the minds of his customers.

ELEX was quick enough to provide a code snippet to solve his problem.

Code snippet to Show Customer Selected Shipping Service in DHL Shipping Label

Although the business case involves Flat rate is printed on the shipping documents, the code snippet will also work for any third-party shipping service other than ones provided by ELEX WooCommerce DHL Shipping Plugin.

Add the following code snippet in the functions.php file of your activated website theme.

add_filter("get_order_shipping_cost_elex_dhl_express", "get_order_shipping_cost_elex_dhl_express", 10, 2);

function get_order_shipping_cost_elex_dhl_express($actual_shipping_cost, $order){
return $order->get_shipping_total();

Based on the above code snippet, the shipping service (WooCommerce default shipping methods or third party shipping service) selected by the customer at the checkout will be printed on the DHL shipping labels and documents.


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 Order’s Flat rate shipping cost and shipping tax on the DHL Commercial invoice (Code Snippet)
Next Get DHL Tracking Numbers for WooCommerce Order IDs (Code Snippet)
You must be logged in to post a comment.