In WooCommerce version 2.1 a new feature was introduced that allowed one order to have multiple shipping packages. Having multiple shipping packages can come in handy in various situations. One that comes to mind at first is when you actually have multiple packages, for example when you can’t ship items together, or when someone has an order that should ship via two different vendors.
Or the other obvious scenario, having to ship one order to multiple different destinations.
Another very useful use-case that a other WooCommerce user pointed me too not long ago was the ability to allow free shipping on just a specific set of products. When using a shipping carrier plugin like UPS it can be hard to set this up, but when splitting your order into multiple packages, and then setup free shipping (with WooCommerce Advanced Free Shipping for example) you can target only the package with the free shipping items, while the UPS plugin still gets the shipping cost for the other products.
Splitting Shipping Package
Just to give a clear example of what ‘splitting a shipping package’ means, this is how it would look like for the user when shipping multiple packages;
Before actually splitting a order in multiple packages, you should first understand what a shipping package is exactly. Obviously a shipping package contains a part of the products to ship, but besides that, it also contains information like the cost, applied coupons and the destination address. A shipping package looks a bit like the following:
- Contents
- {{ All package contents }}
- Contents cost
- Applied Coupons
- 10_OFF
- User
- User ID
- Destination
- Country
- State
- Postcode
- City
- Address
- Address_2
Splitting Shipping Package on Shipping Class
The follow code snippet will split the shipping package based on the shipping class. Each product that has a shipping class A
will be split into a separate package from the other products.
Splitting Shipping Package on Product ID
If you want to split the shipping package based on product IDs you can replace the top part of the code with the following (partial code);
This will setup a separte shipping package for the products with the ID 188, 189 and 190
.
Splitting Shipping Package on Category
The following code is similar to the (partial) code above. Use it by copying into the full code as seen as the first code snippet in this post.
Changing the shipping package name
When you’ve implemented the code above, the shippng should look something like this;
As you can see, there are two shipping packages, each where the user can select a shipping method. One thing that you will see is that the shipping packages are called Shipping #x
. If you want to change this, you’re in bad luck, currently it is not possible to change that package name.
I made a Pull Request to WooCommerce in order to allow the re-naming of the shipping package name, so you can call it what you want from within the shipping package array (as you saw in the first code snippet). When this Pull Request is accepted and it is in WooCommerce Core, I will update this post to include the new feature.
Setting Up Shipping Based on Shipping Package
Not all shipping plugins support shipping packages, so make sure you test everything extensively so your customers will pay the right amount on shipping cost.
My own WooCommerce Advanced Shipping plugin supports shipping packages.
81 thoughts on “Splitting Shipping Packages in WooCommerce”
Hi Jeroen,
I’m looking to implement your code on my website. We currently store small items on-site and any larger items we drop-ship direct from the supplier’s warehouse. We’d like to offer express & standard shipping methods for on-site products/classes and a ship by courier method only for the large dropship products/classes.
Is there a way to ‘group’ shipping classes together into packages, such as ‘small-2kg & medium-1kg’ (on-site) and ‘extra-large-15kg & large-10kg’ (drop-ship), to allow customers to pay/checkout for each package seperately?
Thanks
Hi Oliver,
Let me first note that split shipping packages cause shipping to be calculated separately per package, but it doesn’t allow customers to ‘pay/checkout for each package’.
Its relatively easy to do a conditional check for one of two shipping classes and pack them into one package.
If you’re not comfortable with coding that I’d recommend to take a look my plugin that would also fit your needs: https://woocommerce.com/products/woocommerce-advanced-shipping-packages/
Cheers,
Jeroen
Thanks for the prompt reply. That’s great, separate calculation is what I actually meant/wanted and I appreciate you clarifying that. I’ll have to have a look at your plugin as my coding is very hit and miss!
Thanks again,
Oliver
Could you tell me whether your plugin would be appropriate for me?
I am currently using Dokan plugin based on WooCommerc and I would like to see the shipping cost split between each vendor that the customer purchases from.
I would like the capability that if the customer reaches a particular dollar value on their order they may be entitled to free shipping and this is mentioned to them through the cart experience.
So it could end up being that they order from 3 vendors – vendor a $20 ordered, pay $10 shipping, vendor b – $70 orders pay $0 shipping, vendor c – orders $50, but if they spend up to $60 they get free shipping so in total the shipping only reaches $10.
Can you please tell me if your plugin will do this?
Hi Francine,
The Advanced Shipping Packages would only be able to split the cart into separate packages. If you can distinguish the vendors by something like shipping class or category you’d be able to split those based on those identifiers.
Then for shipping,, do you mean that they get free shipping per vendor if the subtotal per that vendor is above $60? You might be able to setup something like that using my Advanced Shipping plugin, but that also depends on how your shipping cost is setup.
Re it being mentioned in the cart, neither of the plugins above adds any type of notification (outside the scope of the plugin(s)). I do have another that has such type of functionality, but that doesn’t work out of the box with different amounts that are in the cart per vendor. https://aceplugins.com/plugin/woocommerce-advanced-messages/
It would require some additional work to get that working the way I imagine you want it to.
Does that help?
Cheers,
Jeroen
Hello
Love your code how it works.
I have question.
I have two shipping class
“Products” – allow free shipping over 300.00
“Non-Free Shipping”
I setup your code to split order by shipping class which works great.
However, my second shipping package still shows “Free shipping” (by the way I am using your “Advanced Free Shipping Plugin” to determine the free shipping.
Is there a ways to hide free-shipping option for package 2?
Littile help will be appreciated.
Hi Young,
The AFS plugin currently doesn’t have the capability to look at the contents of a package. My other Advanced Shipping does have that capability, though the default ‘subtotal’ condition still looks at the cart subtotal.
I may have a code snippet available that makes it look at the package cost, but I’m not 100% sure about that.
Its also possible of course to manually remove the WAFS rate for the one package. You can look through the package rates to check and remove it.
Another option for that would be to use another plugin of mine that allows you to split the package and exclude rates (the same as above here, just with a UI): https://woocommerce.com/products/woocommerce-advanced-shipping-packages/
Cheers,
Jeroen
Hey Jeroen-
If I have a large product, like a bicycle, that isn’t shipped in a single box, how do I handle that? If you buy a frame-only, it’s box/weight A. If you buy a complete bike, it’s box/weight B + box/weight C.
It seems like the Advanced Shipping plugins are both geared towards creating multiple shipping boxes when dealing with multiple products… but what about one product and multiple boxes?
If it matters, we’re also using the UPS plugin to get dynamic shipping pricing on checkout.
Thanks for the help!
-Justin
Hi Justin,
Splitting one product into multiple packages isn’t possible as the packages do require a product to be in there.
It might work if you actually have separate products for the different parts / like a grouped / composite product for the full bike, but I’m not sure if that is possible for your site.
Note that Advanced Shipping itself doesn’t work with UPS, the Advanced Shipping Packages plugin would allow you to split the cart, hopefully too on the composite products (if you want to give that a try, I haven’t tested it myself). The UPS plugin would then need to support those shipping packages to get separate rates for each of them.
Hope that helps / makes sense.
Cheers,
Jeroen
Hi Jeroen,
how the actual shipping of the Shipping Packages of one order is managed in WooCommerce and how the order status follows the process?
Example: Our customer orders one product, but we send first a tester, and after customer confirms we ship the actual product under the same order id and line. Customer doesn’t see the tester as an item in cart, but we manage it by custom made “between” order status. I was wondering if we can better manage the flow by creating own line item for the tester and have two Shipping Packages. But I couldn’t find out if we can ship the first Package only (to shipping-queue and tester-shipped) and week or two later the second Package (to shipping-queue and completed). How the order status follows Shipping Packages?
Thoughts or tips?
Many thanks in advance,
Pekka
Hi Pekka,
This won’t be possible without additional customization. As there are only order statuses it isn’t possible to have two separate shipping statuses. I do believe there are some plans to change things up and have separate order statuses and shipping statuses, but I’m not sure when those will be introduced.
If you’re starting such customization I’d advise to set things up based on the shipping packages and follow that as much as possible.
Cheers,
Jeroen
Beste Jeroen,
couple of short ones:
Do you know if there’s a demo somewhere to test Advanced Shipping Packages?
Do have experience or know how Advanced Shipping Packages works with WooCommerce Warehouses plugin?
Bedankt,
Pekka
Hi,
There’s no demo available, can’t tell how it works with that plugin, haven’t tested it.
Cheers,
Jeroen
Hi, I tried the code, and everything works fine except TAX calculation.
All taxes starting from the second package aren’t calculating. In buyable version taxes calculating properly?
Or do you have any idea why it is might happen?
Hi Andy,
Not sure why its not calculating tax for you. There are no known bugs in the plugin regarding taxes.
Might be something in your setup, don’t believe packages should influence taxes like that.
Cheers,
Jeroen
Just bought this plugin and there is still issue with Tax calculation and package names do not display properly as well.
I there a way to fix it? Please contact me directly thru email
Hi Any,
Please contact WooCommerce.com support for any support questions regarding the Shipping Packages plugin, as its sold through their system I cannot answer support questions directly.
Cheers,
Jeroen
Seems like the code doesn’t work now sadly. Which means one is forced to have to buy the plugin. This is as of wc 3.1.0 btw.
Hi Dani,
Just tested the first code snippet on WC 3.1 and seems to work perfectly with me. I’ve got no reason to believe WC has changed anything in regards of shipping packages here. The plugin itself hasn’t required or had a update for WC 3.1 either.
There’s likely something else going on why the snippet isn’t working for you.
Regards,
Jeroen
I have UPS & USPS Shipping methods, but I want to apply each method to a specific product category, such that when one checkouts only the respective shipping method for that particular category is set. If there are two different products from different categories then both UPS & USPS appear on checkout. How can i go about this? Thank you
Hi Munaye,
You can do this by using the Advanced Shipping Packages plugin. With that you can create the packages per category, and exclude shipping methods per package to only show the respective shipping carrier option.
Hope that helps!
Jeroen
Hey Jeroen,
I want to enable free shipping when over $100 is spent in certain categories, is there a simple way to do this?
Thanks
Is it possible to split two products into two shipping packages with Advanced Shipping Package plugin?
I should have been more explicit that the two products are the SAME product. So if I have two shirts – both same product – how do I indicate to separate these into two packages?
Hi Mary Jo,
It is not possible to split one product into two packages with the plugin.
Is it also possible to show the shipping price per product on cart?
Hi Philip,
To do that you could split each product in a separate package so the shipping options are shown separately per product.
Alternatively you could also consider using the Extra Shipping Options plugin to display a ‘Description’ option, not sure if it will fully fit your needs, but it may 🙂
Cheers,
Jeroen
Great code! I’m trying to split shipping into three possible variables:
1. Regular, courier ship items
2. Free ship items
3. Freight ship items (manually calculated after order).
I have created the free ship class and the manual ship class. Is there a way to include both classes in the array variable?
Thank you!
Dave
As this article was never updated if anyone else was looking for how to change the Shipping Package name, here’s a snippet I wrote which implements a filter to change the text to Package 1, Package 2 etc:
add_filter( ‘woocommerce_shipping_package_name’, ‘change_shipping_package_name’, 10, 3 );
function change_shipping_package_name($shipping_name, $index, $package) {
$shipping_name = “Package “.++$index;
return $shipping_name;
}
Hi Jeroen,
It would be nice if you can update the post content about the pull-request to make possible to change the shipping package name 🙂
Thanks for the great article, it saved me a lot of time 🙂
Hoi Jeroen
Is there a plug in code that allows for separate shipping charges when an item in shopping basket is on back order? My current woo-commerce shop only charges one shipping rate, thus meaning that when an item on back order arrives, I will have to ship it to the customer on my own costs. (The shipping is most of the times almost more than the item itself)
Anyway around this issue?
Hi Ilze,
You can do this with my Advanced Shipping Packages plugin 🙂
Cheers,
Jeroen
If I setup Free Shipping for one “package” and FedEx ground for the second “package”, how do I hide the Free Shipping button on the FedEx ground package option?
Hiding shipping options in a package is not something covered in this post. You’d need a additional customization for that, or use the Advanced Shipping Packages plugin which has a feature build in for that.
I am having the same Tax issue the previous user mentioned. Tax calculates fine for one package but not the second. Do you know if this issue has been fixed with the paid plugin?
Hi Joe,
My prior answer to that earlier mention is still valid; no known issues with the plugin for that.
Cheers,
Jeroen
Hey,
I combined your Code with the Advanced Shipping Plugin. I could not find the correct conditions for my case.
I will set free shipping for a package if the Sub-Total of that package is greater than a certain value (not the sub total of the cart).
Is that possible?
Thanks
Johannes
Hi Johannes,
Out of the box it is not possible to setup a condition based on package amount, but this can be done with a custom condition for the plugin. Feel free to reach out through the support channel for the shipping plugin if you’d like help with this; https://jeroensormani.com/woocommerce-advanced-shipping/support/
Cheers,
Jeroen
Do you know of a plugin that can assign multiple, different box dimensions & weights for a single variable product? We are unable to fit our variable product into 1 shipping box – its takes 4 shipping boxes for just 1 product. We need to add/assign/specify specific dimensions and weights of multiple box that make up 1 product to be able to get a live FedEx shipping cost using our Fed Ex account negotiated rates. Ideas?
Hi Ari,
Unfortunately this is not something that is uniformly supported by in WooCommerce. This would require to look at the carrier plugin and see if the request to it can be modified to make it so the product requests for the multitude of boxes. If this is possible would depend on the carrier plugin that is being used.
Cheers,
Jeroen