WooCommerce: Show ony Free shipping if Available

By default, every shipping method in a zone is shown to the customer at the checkout page.

In case you only want to show free shipping method if it’s available for your customer. maybe you offer free shipping for some products or for certain total order cost like “free shipping for $100+ shipping”.

You can add the following snippet at bottom of your functions.php or use Code snippets plugin if you are not comfortable editing theme files directly.

** Hide shipping rates when free shipping is available.
 * Updated to support WooCommerce 2.6 Shipping Zones.
 * @param array $rates Array of rates found for the package.
 * @return array
function my_hide_shipping_when_free_is_available( $rates ) {
	$free = array();

	foreach ( $rates as $rate_id => $rate ) {
		if ( 'free_shipping' === $rate->method_id ) {
			$free[ $rate_id ] = $rate;

	return ! empty( $free ) ? $free : $rates;

add_filter( 'woocommerce_package_rates', 'my_hide_shipping_when_free_is_available', 100 );

After you add the above code snippet, Users will not see other shipping methods on the checkout page if they are eligible for free shipping.

Yes, it was that easy

I hope this article helped you to Only show free shipping if available. Have any question? Don’t forget to leave a comment below…

If you liked this article, then please follow us on Facebook for more WooCommerce and WordPress tutorials. You can also find us on Twitter.