How to Hide WooCommerce Shipping Methods based on Different Conditions?
Having multiple shipping and payment methods can be critical to increasing your WooCommerce store’s conversion rate. You may sometimes require to restrict the availability of specific shipping methods based on multiple factors. For example, you may need to disable free shipping for certain products or regions.
In this article, we will try to learn how to hide WooCommerce shipping methods based on various conditions. Out of all shipping methods, free shipping is the most popular and widely used.
It helps to improve customer satisfaction, reduce cart abandonment and increase the retention rate. Unfortunately, WooCommerce doesn’t allow you to choose which shipping methods to display on the cart page. So, let’s deep dive into all the how’s and why’s of the topic.
Why hide WooCommerce shipping methods?
WooCommerce without a doubt is the most popular and widely used eCommerce platform. By default, it offers you multiple shipping methods including, local pickup, free shipping, and flat-rate shipping.
You can also configure shipping methods based on predefined shipping zones. For instance, free shipping is only offered for a select few postcodes close to the store location and flat-rate shipping is available for the rest.
Additionally, the majority of customers find it challenging to choose a shipping option that is both advantageous and affordable. Hiding specific delivery options makes it easier for them to choose. Default WooCommerce shipping can be used for this, but it offers limited options.
Aside from location, store owners may also need to hide shipping methods based on different conditions.
These conditions can be based on the following:
A few examples include:
Methods to Hide WooCommerce Shipping Methods
In order to hide shipping methods, you can use two different methods. You can either achieve this by using code snippets or use a third-party plugin. Both methods have their own pros and cons and now we will discuss in detail both methods.
Using Code Snippets to Hide Shipping Methods based on Various Conditions
Let’s discuss code snippets that you can use to hide shipping methods based on different conditions. We will take the above-discussed scenarios as examples of how to use code snippets to hide shipping methods.
Scenario 1: Hide shipping method based on order weight
Use the following code snippet to hide the free shipping method if the order weight exceeds a particular limit.
/**
* Hide free shipping when the order weight is more than (*)kgs.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function ts_hide_free_shipping_for_order_weight( $rates, $package ) {
$order_weight = WC()->cart->get_cart_contents_weight();
if ( $order_weight > * ) {
foreach( $rates as $rate_id => $rate_val ) {
if ( 'free_shipping' === $rate_val->get_method_id() ) {
unset( $rates[ $rate_id ] );
}
}
}
return $rates;
}
add_filter( 'woocommerce_package_rates', 'ts_hide_free_shipping_for_order_weight', 100, 2 );
You can add this code snippet to the theme editor menu of your WooCommerce store. The “woocommerce_package_rates” filter is used in the code to change the product rates on the cart page. When the order surpasses the price limit of 5kg, the above code will hide the free shipping option.
Scenario 2: Hide shipping method based on cart subtotal
The other example is hiding shipping methods when the cart exceeds a particular subtotal. Continuing the previously discussed example, you can use the following code to hide specific shipping methods if the cart subtotal exceeds $300.
/**
* Hide shipping rates when the order total is more than $3000.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function ts_hide_shipping_for_order_total( $rates ) {
$free = array();
$order_total = WC()->cart->get_subtotal();
if( $order_total > 300 ) {
foreach ( $rates as $rate_id => $rate ) {
if ( 'free_shipping' === $rate->get_method_id() ) {
$free[ $rate_id ] = $rate;
}
}
}
return ! empty( $free ) ? $free : $rates;
}
add_filter( 'woocommerce_package_rates', 'ts_hide_shipping_for_order_total', 100 );
When the order subtotal exceeds $300, the “woocommerce_package_rates” filter returns an array of only free shipping methods.
Method 2: Using the third-party plugins to hide shipping methods
Those who are not familiar with coding can use third-party plugins to hide WooCommerce shipping methods. There are a large number of plugins available in the market for this purpose.
The difficult task is to select the one that fulfills your requirements. So, let’s discuss in detail some of the most useful and powerful plugins to hide WooCommerce shipping methods.
1. Add custom shipping icons & hide shipping methods
The Add custom shipping icons & hide shipping methods plugin allows store owners to hide WooCommerce shipping methods based on different conditions. The plugin enables you to hide shipping methods for different products based on multiple factors.
You can also add custom shipping icons by using this plugin which is always an extra benefit. For example, you can hide other shipping methods when free shipping is available.
Another perk is the price. When compared to other plugins, it offers the most reasonable price. You can also apply conditional logic to enable free shipping based on multiple factors such as location, categories, and SKUs.
Some of the major features of the plugin include:
- Shipping classes
- Product categories
- Product SKUs
- Order subtotal
- Total weight
- location/postal code
- User role
Price: The plugin is available at only $4.09 per month
Download: Add custom shipping icons & hide shipping methods
2. Advanced Flat Rate Shipping Plugin For WooCommerce
Advanced Flat Rate Shipping Plugin is one of the best WooCommerce plugins that provides you the flexibility to manage shipping methods and flat rates.
The plugin enables you to create an effective delivery strategy with multiple flat-rate shipping options. With conditional rules, you can create various shipping rates based on your recurring shipping patterns.
The plugin offers you features such as:
Price: The plugin is available at only $8.25.
Download: Advanced Flat Rate Shipping Plugin For WooCommerce
3. Hide Shipping Method For WooCommerce
You can optimize the shipping strategy for your WooCommerce store using the Hide Shipping Method For the WooCommerce plugin. It will help you set up complex conditions that will restrict the use of different delivery methods.
You have a lot of flexibility using the plugin to hide shipping alternatives based on product characteristics, delivery location and time, etc. Additionally, you can control your shipping strategy by mixing various rules and producing complicated situations.
Furthermore, when free shipping is provided, the plugin makes it very simple to construct conditions that hide other shipping alternatives. Installation and configuration of the plugin are simple. Major features include
Price: The plugin is available at only $6.59.
Download: Hide Shipping Method For WooCommerce
Use Cases to Hide Shipping Methods
WooCommerce has multiple shipping methods and these shipping methods can be managed based on multiple factors. Some of the most common use cases are as follows:
Use Case 1: Hide Shipping Methods based on Product Category
The first scenario is to hide certain shipping methods based on product categories. You can create rules to hide shipping methods for all product categories at once or multiple rules for multiple product categories.
Use Case 2: Hide other Default Shipping Methods if Free Shipping is Available
WooCommerce provides three types of shipping methods by default. In order to hide all other shipping methods if free shipping is available, you can use multiple plugins. You can create rules for all or selective products. You can also set rules based on different conditions such as location, time, SKUs, and much more.
Use Case 3: Hide based on Shipping Classes
Based on the shipping classes you establish in your WooCommerce store, you can hide specific delivery methods. You can choose products with no shipping classes or numerous shipping classes by using any of the above plugins.
Use Case 4: Hide Shipping Methods Based on Order Weight
Based on certain order weight requirements, you can hide specific shipping methods:
Use Case 5: Hide Shipping Methods Based on User Roles
Another case is to hide shipping methods based on user roles. You can create and manage different shipping rules for various user roles. For example, Free shipping is only available for subscribers or contributors.
Final Thoughts
For eCommerce store owners, shipping could be a challenging task depending on the nature of the products. You can manage and hide shipping methods and shipping costs per order, item, or shipment class.
The default options won’t do when you have customers from all over the world and a wide variety of products. You will need to spend money on specialized plugins in order to configure sophisticated flat-rate options.
We hope that this article will clarify how to hide specific WooCommerce shipping options for specific products.
You can switch between the two methods above and use the plugins mentioned. Look closely at your store to identify the best solutions for managing your shipping procedure and peak sales.