Skip to content

Instantly share code, notes, and snippets.

@shadimanna
Created December 2, 2019 13:45
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 shadimanna/b4a6ab1d4f8efcf6061cb5da3bbdb7e4 to your computer and use it in GitHub Desktop.
Save shadimanna/b4a6ab1d4f8efcf6061cb5da3bbdb7e4 to your computer and use it in GitHub Desktop.
add_filter('pr_shipping_dhl_label_args', 'modify_order_id_to_number', 10, 2);
function modify_order_id_to_number($args, $order_id) {
$order = wc_get_order( $order_id );
$args['dhl_settings']['dhl_label_ref'] = $order->get_order_number();
return $args;
}
@drhgmarketing
Copy link

Thanks a lot for that code! I use Woocoommerce and DHL Paket plugin on Wordpress. My goal is to put some product information on my DHL label. Could be at Shipper Contact, Customer Contact or Reference ID field. I tried to access the variables on the label via add_filter('pr_shipping_dhl_label_args'...) like you show in your code examples. But i am not able to access any of the arguments. Nothing changes on the label. Do you have an idea what the problem is? For example i tried this:

add_filter('pr_shipping_dhl_label_args', 'modify_order_id_to_number', 10, 2); function modify_order_id_to_number($args, $order_id) { $args['dhl_settings']['dhl_label_ref'] = "dummy text"; // or this: $args['shipping_address']['phone'] = "dummy text"; return $args; }

Nothing happens on the label. Do you have an idea what might be wrong? Thank you very much!

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