What can we help you with?

How to remove Signature options from DHL shipping label, if the country is Switzerland? (Code Snippet)

With the following code snippet, you can remove signature options from the request (sent to DHL), if destination country is Switzerland.
Add the following code to Appearance > Editor > functions.php file.

add_filter( 'wf_dhl_label_request', 'wf_alter_dhl_request', 10, 2 );
function wf_alter_dhl_request($xmlRequest, $order_id){
global $woocommerce;
$order = new WC_Order($order_id);
if( $order->get_shipping_country() != 'US') {
return $xmlRequest;

$signature_options = array('SX','SA','SB','SC','SD','SE','SW');
$xml_obj = new SimpleXMLElement($xmlRequest);
foreach ($xml_obj->SpecialService as $SpecialService) {
if( in_array($SpecialService->SpecialServiceType, $signature_options)){

$doc = new DOMDocument();
$doc->formatOutput = TRUE;
return $doc->saveXML();

Using this, shipments to Switzerland will not throw an error if you have enabled the signature option for other countries.


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 How to set up different accounts to vendors for DHL international and domestic shipping? (Code Snippet)
Next How to convert Base currency to DHL currency, dynamically? (Code Snippet)
You must be logged in to post a comment.