This is a common request from WooCommerce users:
I want to ship specific products for free while some others will have shipping costs, but when a product having free shipping is in cart with another product that has shipping costs, free shipping isn’t available at all, what to do?
There’s a solution to that! And you don’t need any plugins to solve this issue. Based on a post by Mike Jolley, I’d like to explain how to use different shipping methods on a per product basis in the same cart. Let’s say you have two products, one that must be shipped for free, and a second one having a flat shipping cost (that would work with rates based on APIs as well, like UPS, USPS, Fedex, Canada Post, Australia Post etc…). The 1st step is to create 2 shipping classes, in Products > Shipping Classes:
You need to create a “Free” shipping class. You can create as many other shipping classes as ou want.
The next step is to assign classes to each product:
Now that you assigned classes to products, you need to define flat rates per classes in WooCommerce > Settings > Shipping > Flat Rate:
Make sure that you setup a cost equal to zero for the free shipping class.
Finally you need to filter the shipping package using custom code and separate products from one package to two packages having each its own shipping method. Add the following snippet in the file called functions.php in your theme folder:
Please note that you need to use the free shipping method slug at line 14. And the final result in the cart is the following:
That’s it! I hope that will save you some headaches! If you enjoyed this post, make sure you share it on Twitter!
Similar posts by awesome folks:
- Apply Free Shipping to Certain Products in WooCommerce by Bryce Adams
- Disable Free Shipping on a per Product Basis in WooCommerce by Patrick Rauland
Leave a Reply
You must be logged in to post a comment.