Hide other shipping methods when “Free Shipping” is available

Overview

By default, WooCommerce will show all shipping methods that match the customer and the cart contents. This means Free Shipping will also show along with Flat Rate and other Shipping Methods. The functionality to hide all other methods and only show Free Shipping requires either custom PHP code or a plugin/extension.

If you’d like to see this feature added to WooCommerce core, visit our Ideas Board and add your vote to it. The more popular an idea becomes, the more of a priority it is for our developers to review.

Adding code

Before adding snippets, clear yourย WooCommerce cache. Go toย WooCommerce > System Status > Tools > WooCommerce Transients > Clear transients

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme.

PHP Snippet

How do I show only Free Shipping?

Hides everything but free_shipping if it’s available and is compatible with Shipping Zones.

https://gist.github.com/woogists/bd6938ccfdea0d03df5d060902561378

How do I show only Local Pickup and Free Shipping?

Hides everything but free_shipping and local_pickup if it’s available and is compatible with Shipping Zones.

https://gist.github.com/woogists/57e4cf73f083190c0e00bd59f060f87d

Show only free shipping in all states except…

Show only free shipping in all states except the exclusion list. Hide free shipping if the customer is in one of the states listed:

https://gist.github.com/woogists/af60e9a3eb2a2ffadc67a0a8d04b77fa

Is there a plugin available for this?

Yes, you can also use this free plugin instead of the first two snippets: https://wordpress.org/plugins/wc-hide-shipping-methods

Enable Shipping Methods on a per Class / Product Basis, split orders, or other scenarios?

Need more flexibility? Take a look through our premium Shipping Method extensions.


Keep yourself in the loop!

This field is hidden when viewing the form
This field is hidden when viewing the form
This field is hidden when viewing the form