What can we help you with?

How to set up different accounts to vendors for DHL international and domestic shipping? (Code Snippet)

This article explains how to set up different accounts to vendors for DHL international and domestic shipping. Refer the product page to know more about other various features of the plugin.

DHL Express has two account types; Import and Export account. These accounts are mostly used by shop owners who have other vendors selling their product in the shop and also who ships from different countries. When it comes to multi-vendor integration, our ELEX WooCommerce DHL shipping plugin works best with the Dokan multi-vendor plugin.

How to distinguish the import and export account number? The Import account number always start from 95xxxxxxx or 96xxxxxxx. Any other number series other than 95 and 96 are Export account number.

But what happens when you have both accounts and the plugin has only one field to enter your account number?
Our developers have come up with a solution to use a code snippet to handle two account numbers. We’ll explain here in what situation you can use the two account numbers and why.

The Import account number is mainly used to ship the products from outside the shop’s base country. Usually, the import account has the contracted rates only if the shipping country is not from the shop’s base country. So if the product is being shipped from the home country, DHL usually provides the export account type with better-contracted rates.

The code snippet (given in the later section of this article) will provide the solution where if the ship-from country is NOT shop’s base country. It will use the account number entered in the plugin settings (you need to enter the Import account number in the plugin settings). If the ship-from address is the shop’s base country the account number in the code snippet will be used.

/*Filter to switch account numbers for multi-vendor setup */
add_filter('switch_account_number_action_express_dhl_elex', 'switch_account_number_express_dhl_elex', 10, 1);

function switch_account_number_express_dhl_elex($switch_account_numbers_input){
$stored_vendor_account_number = '111111111';
$stored_vendor_country_code = 'XC';
$stored_vendor_payment_country_code = 'XC';

if(($stored_vendor_country_code === $switch_account_numbers_input['source_country_code'])){
return array('payment_account_number' => $stored_vendor_account_number, 'payment_country_code' => $stored_vendor_payment_country_code);
}else{
return array('payment_account_number' => $switch_account_numbers_input['account_number'], 'payment_country_code' => $switch_account_numbers_input['payment_country_code']);
}
}

You have to make the following changes in the code snippet, accordingly:

  1. $stored_vendor_account_number = ‘111111111’; – change the account number to the export account number your DHL account manager provided.
  2. $stored_vendor_country_code = ‘XC’; – Change the country code to the Shop’s country code. It should be a two-character country code.
  3. $stored_vendor_payment_country_code = ‘XC’;- Change the country code to the Shop’s country code. It should be a two-character country code.

With this solution when the Vendor address is the same as the shop’s base country, it will use the export account number in the code snippet. If the vendor address is not the same as the shop’s base country, it will use the Import account number entered in the plugin settings.

 


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 Alter DHL Express Commercial Invoice Title in ELEX WooCommerce DHL Shipping Plugin (Code Snippet)
Next How to remove Signature options from DHL shipping label, if the country is Switzerland? (Code Snippet)
You must be logged in to post a comment.