What can we help you with?

Ship Smaller Items Using WooCommerce Australia Post plugin, and Larger Items with DHL

This is a business case from our customer using ELEX WooCommerce Australia Post Shipping Plugin with Print Label & Tracking. The problem he’s facing is with shipping cost calculation for larger items. Australia Post has a few weight restrictions and also the package size limit. They have package length limit of max 105 cm or max volume: 0.25 m³, and max package weight of 22 kg.

This customer has a product dimension of 120 x 120 x 45 cm but even if the weight is below 22 kg he still don’t get shipping rates for that product. So, right now if that product and some other smaller items are in cart he gets shipping calculated for the other products and the API just ignore the shipping cost for the larger item and return only for the smaller items. So he’s losing money on shipping when larger items are in cart. What he could do is to assign separate shipping class for the smaller items and another shipping class for the larger items and use different carriers for different shipping classes. This could be very simple if there’s only one item in cart. But when there are multiple items from different shipping classes, we need to show both Australia Post option for the smaller items and the other carrier’s shipping options for the larger items. So we’ll have to split the cart based on the shipping class and the customer will have to choose different shipping options for different shipping classes.

In this article, I’ll explain how to set up the plugins to achieve this, and I’ll also explain what are the other plugins you require to make this work. ELEX WooCommerce DHL Express / eCommerce / Paket Shipping Plugin with Print Label is capable of shipping larger items so we’ll take that plugin as an example to ship the larger items.


ELEX WooCommerce Australia Post Shipping Plugin with Print Label & Tracking

First you need to purchase the Australia Post plugin and set it up. If you’re using a contract account (e-parcel or Star track), you need to request for the API credentials by registering in their Developer’s portal for Shipment and Tracking. Enter the details you received from the Australia Post Team in the plugin settings. Make sure you check the option “contract” to be able to enter your Account number and the secret key. The API key should be provided by Australia Post during registration. If you’re using non-contract account type you need to disable the contract option and enter only the API key. Please note only the contract account type has the option to print labels and manifests. The non-contract set up will allow you to get the shipping rates in the Cart and Checkout pages, but it will not have the print label and manifest features. Once the account set up is done, go to the ‘Rates and services tab’ in the plugin settings,and enable both domestic and International services.  Now once all set up is done, please add a few products to cart and check if you’re getting any Australia Post services in the cart/checkout page. All products need to have weight and dimensions set up in advance. If you’re using ‘pack items individually’ or ‘weight based packing’, you need to add dimension to the products such that at least for 2 dimensions, the value is 5 cm. For example, 5 x 5 x *cm, where * can be any non-zero value. If you’re still not getting any shipping options, do contact our support team here.

ELEX WooCommerce DHL Express / eCommerce / Paket Shipping Plugin with Print Label

You need to open DHL Express account and register in https://xmlportal.dhl.com and DHL will provide the Test and Live API credentials. Enter the API credentials and account number in the plugin settings, also enter the shipper’s address. If you’re using the Test credentials make sure you disable the “Show DHL Account Rates” option under the Rates and services Tab, if you’re using the Live credentials enable that option. Add products to cart and check if you’re getting shipping options from DHL in the cart or checkout page. Make sure all products have weight and dimension.

Set Up Shipping Class

You need to set up the shipping class in WooCommerce > Settings > Shipping > Shipping class. You’ll need to create one shipping class for the smaller items and name the slug as “small”. And, one for the larger items and name the slug as ‘large’. Assign the shipping class to the products accordingly. To assign the shipping class you can go to edit the product and under the shipping tab choose the shipping class from the drop down accordingly.

Show Hide Shipping Method

You can download this free plugin here. And you only need to hide the DHL shipping option for the smaller products so that only Australia Post will be available for that shipping class. Once this plugin is installed you can go to the WooCommerce settings and click on Manage Shipping Methods. Under the shipping class field, choose the ‘small products shipping class’ and under the shipping class ID you can enter “wf_dhl_shipping” without  quotes.

Split Cart Based on Shipping Class

You can split the cart based on shipping class so that the larger items will have different shipping options and the smaller items will have different shipping options. Install the plugin code snippets and add the below code as new code snippet.

add_filter( 'woocommerce_cart_shipping_packages', 'wf_split_cart_by_shipping_class_group' );
function wf_split_cart_by_shipping_class_group($packages){
//Reset packages
$packages = array();

//Init splitted package
$splitted_packages = array();

// Group of shipping class ids
$class_groups = array(
'group1' => array('small'),
'group2' => array('large'),

foreach ( WC()->cart->get_cart() as $item_key => $item ) {
if ( $item['data']->needs_shipping() ) {

$belongs_to_class_group = 'none';

$item_ship_class_id = $item['data']->get_shipping_class();


foreach($class_groups as $class_group_key => $class_group){
if(in_array($item_ship_class_id, $class_group)){
$belongs_to_class_group = $class_group_key;


$splitted_packages[$belongs_to_class_group][$item_key] = $item;

// Add grouped items as packages

foreach($splitted_packages as $splitted_package_items){
$packages[] = array(
'contents' => $splitted_package_items,
'contents_cost' => array_sum( wp_list_pluck( $splitted_package_items, 'line_total' ) ),
'applied_coupons' => WC()->cart->get_applied_coupons(),
'user' => array(
'ID' => get_current_user_id(),
'destination' => array(
'country' => WC()->customer->get_shipping_country(),
'state' => WC()->customer->get_shipping_state(),
'postcode' => WC()->customer->get_shipping_postcode(),
'city' => WC()->customer->get_shipping_city(),
'address' => WC()->customer->get_shipping_address(),
'address_2' => WC()->customer->get_shipping_address_2()
return $packages;

You need to enter the shipping class slug into the code snippet. Right now I’ve given the shipping class slug in the code as small and large as you can see in the code snippet above in line 11 and 12. Since we have only two shipping class required it will split into two shipping sections when there’s products from shipping class small and large in cart.

Below screenshot shows how the cart page will appear after all the set up, the small items will have Australia Post option and the larger items will have the DHL option.

With this solution, when you have multiple items with different shipping classes you’ll have to split cart and choose different shipping options for each class, and you’ll no longer have the issue with shipping cost calculating incorrectly when large items as also present in the cart.  Hope this article have helped with the current business case. Do let us know if you have any queries or if you have any business cases that need our help.

To explore more details about the shipping plugins, please check out the product pages.

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


Previous Show Australia Post Satchel Rates or Custom Packing Regular Post based on Order Weight on WooCommerce
Next How To Use The Australia Post Plugin For Domestic Shipments and Use The DHL Plugin For All International Shipments Except For Few Countries
You must be logged in to post a comment.