Design and Development

Hide WooCommerce Shipping Methods When Free Shipping is Available

To hide shipping methods when free shipping is available in WooCommerce, you can use the built-in conditional logic feature in WooCommerce. Here is an example of how you can do this:

  1. In the WordPress dashboard, go to WooCommerce > Settings > Shipping.
  2. Click on the shipping method you want to hide when free shipping is available.
  3. Scroll down to the “Shipping Method Options” section.
  4. Under “Availability”, select “Customers can select this method only if…”
  5. Select “Other shipping methods are not available” from the “Conditions” dropdown.
  6. Save the changes.

Hiding Shipping Methods with Code Snippet

This will ensure that the shipping method you selected will only be visible when free shipping is not available. You can also use the “Advanced Shipping Methods for WooCommerce” or custom code like:

add_filter( ‘woocommerce_package_rates’, ‘hide_shipping_methods_when_free_shipping_is_available’, 10, 2 );

function hide_shipping_methods_when_free_shipping_is_available( $rates, $package ) {

    // Loop through the shipping rates

    foreach ( $rates as $rate_id => $rate ) {

        // Check if free shipping is available

        if ( ‘free_shipping’ === $rate->method_id ) {

            // Loop through the other shipping methods

            foreach ( $rates as $rate_id => $rate ) {

                // Check if the method is not free shipping

                if ( ‘free_shipping’ !== $rate->method_id ) {

                    // Remove the method

                    unset( $rates[ $rate_id ] );

                }

            }

            break;

        }

    }

    return $rates;

}

Using third-party plugins to Hide Shipping Methods

Let’s see how the WooCommerce hide shipping plugin may be used to quickly disable the WooCommerce Shipping Method for selected Products on your WooCommerce shop. The Add custom shipping icons & hide shipping methods plugin might be used to achieve this. This plugin can be one of the most complete choices if you want to restrict the available delivery options based on a variety of criteria. The plugin allows you to turn off both WooCommerce’s built-in and third-party shipping options.

Depending on the products, category, IP, order total weight, accessibility of substitute shipping methods, etc., shipping methods may be hidden. You might wish to develop various rules to conceal different distribution techniques depending on your plan. Unexpectedly, the plugin also allows you to conceal specific shipping company services. Depending on the user’s role, certain shipping methods may not be available.

Let’s see how you can hide and manage WooCommerce shipping methods with the plugin.

  • Download the Add Custom Shipping Icons & hide shipping methods plugin .Zip file from the WooCommerce Marketplace.
  • Go to WordPress > Admin > Plugins > Add New and upload the plugin you downloaded.
  • Install and activate the plugin.

How to Hide WooCommerce Shipping Methods

From the backend of your website, go to WooCommerce > Settings and click on the Custom Shipping Icons tab. You can create and configure rules to hide WooCommerce shipping methods in this section. Editing and deleting rules are possible in the “Manage Rules” section. You can modify the following settings in the “Create Rule” tab:

  • Rule Name: If you don’t enter a name, the plugin will automatically generate one for you.
  • Choose Shipping Methods to Hide: Select the shipping methods you want to conceal. You have a choice of third-party shipping, local pickup, flat-rate delivery, and free shipping.
  • Rule Requirements: Choose the delivery method for which you want to make the rule to hide it. From the following approaches, you can choose:
    • Shipping Class: Based on shipping classes, hide shipping methods
    • Product SKU: Create a rule to hide shipping based on the product SKUs.
    • Category: Check this box to make delivery methods based on product categories invisible.
  • Order Weight: Based on order weight, conceal shipping techniques. Rules can be made based on various weight conditions:
    • None
    • All order weights
    • Greater than or equal to a specific weight
    • Less than or equal to a specified weight
    • Equal to the specified weight
    • Between a specified minimum and maximum weight
  • Order Subtotal: Using the cart subtotal as a base, create hidden shipping rules. You can define rules depending on various cart total criteria, similar to order weight.
  • Countries: Hide shipping techniques depending on nations, areas, states, and particular places
  • Postal Code: To hide delivery options depending on zip or postal codes, add multiple codes.
  • User Roles: For any certain user roles on your WooCommerce store, hide the shipping methods.

Use Case: Hide Other WooCommerce Shipping Methods if Free Shipping is Available

If free shipping is offered in certain shipping zones and under certain circumstances that you specify, the plugin enables you to hide all other paid shipping options. Follow these steps to do so: To hide shipping ways, go to WooCommerce > Settings > Custom Shipping Icons. Here, choose “Free Shipment” for the shipping method and type in the name of the regulation. To display free shipping and conceal all other shipping options, create rule conditions. The product category, SKUs, postal code, nation, weight, cart total, and shipping classes can all be used to build conditions.

Article Summary

This post demonstrated how to use the Hide WooCommerce Shipping Methods based on Shipping Classes and Zones plugin to hide WooCommerce shipping methods depending on a variety of characteristics, including WooCommerce shipping classes, shipping zones, cart subtotal, and product type.

Email

Abdullah Sadiq