Website Building » WooCommerce » How to Hide WooCommerce Shipping Method?

How to Hide WooCommerce Shipping Method?

Last updated on January 20, 2023 @ 3:56 pm

It is no secret that many WooCommerce stores offer free shipping. However, there are still some store owners who prefer to hide the shipping method until the customer reaches a certain order total.

In this article, we will show you how to hide WooCommerce shipping method.

There are two ways to hide WooCommerce shipping method. The first way is to use a plugin like Hide Shipping Method for WooCommerce.

This plugin allows you to hide all shipping methods until the customer reaches a certain order total.

The second way to hide WooCommerce shipping method is by using a code snippet. Simply add the following code to your child theme’s functions.php file or via a plugin like Code Snippets:

PRO TIP: Please be aware that there is a risk involved when hiding WooCommerce shipping methods. This could lead to customers not being able to see important information about their order, such as delivery times and costs. If you are going to hide WooCommerce shipping methods, we recommend that you do so with caution and only do so if absolutely necessary.
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;
     break;
    }
  }
return ! empty( $free ) ? $free : $rates;
}
add_filter( 'woocommerce_package_rates', 'my_hide_shipping_when_free_is_available', 100 );

You can also use this code snippet to only show the free shipping method when it’s available.

Conclusion:

Hiding WooCommerce shipping methods can be useful if you want to encourage customers to spend more in order to qualify for free shipping. There are two ways to do this, either by using a plugin or by adding a code snippet.

Drew Clemente

Drew Clemente

Devops & Sysadmin engineer. I basically build infrastructure online.