wedevtrust Logo

WooCommerce Free Shipping Excluded

WooCommerce Shipping
Image | CC0 pixabay

How to Exclude Shipping Classes from Free Shipping in WooCommerce

Let’s say we have a webshop selling accessories that can be shipped in ordinary parcels. You want to ship those for free when the order exceeds 100€. This is classic free shipping per minimum order value.

Now we decide to sell furniture as well with said webshop. Furniture has to be shipped differently ~ per trucking company ~ and should be excluded from free shipping. Here is what we do.

Learn

Keep reading for an explanation on how to go on about it.

Keep reading

The button will take you to a step by step guide through the process.
Continue

Watch

Take a look at what this is all about and see the feature in action.

Go there

The button will take you to a project were we implemented this feature.
Baby Kochs

Download

Get the files from GitHub immediately and for free.

From GitHub

The button will take you to GitHub were the files you need are available.
GitHub

As bulk shipping is calculated depending on size or weight, whichever turns out to cost more, it would be wise to not get into the complicated details and just create shipping classes for bulky goods roughly representing the costs. When shipping that giant wardrobe we want a shipping class with a slug ‘bulk-giant-wardrobes’ to then put costs to it depending on shipping zones. Here is what we need to add to our functions.php then.

WooCommerce is providing a hook (woocommerce_shipping_free_shipping_is_available) ~ an attachment point for our own logic ~ in the process of figuring out if free shipping should be available to the shopping cart or not.

We run $is_available through our own function after WooCommerce has decided if it should be true or false. We then cycle through all items in the shopping cart looking for a specific shipping class. When a shipping class slug starting with ‘bulk’ is found, we exit our function returning false, and the giant wardrobe is not available for free shipping anymore.

Share

Related Posts

Time to Update

Maintenance of High Turnover WooCommerce Stores

What to do when plugin updates suddenly cause problems for a high-traffic online store? We were faced with this task when a maintenance interval looked promising at first, but then led to inaccessibility of our client’s high-volume WooCommerce store under load.

GET IN TOUCH

Contact.