Adding code
Before adding snippets, clear your WooCommerce cache. WooCommerce > System Status > Tools > WooCommerce Transients > Clear transients
You need to add this code to your child theme’s 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 file as this will be wiped entirely when you update the theme.
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.
How do I show only Free Shipping?
Hides everything but free_shipping
if it’s available and is compatible with Shipping Zones.
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.
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:
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