Hide Other Shipping Methods when “Free Shipping” is Available in WooCommerce

Do you want to hide other shipping methods when ‘Free Shipping’ is available in WooCommerce?

By default, WooCommerce shows all shipping methods that match the customer’s criteria and cart contents. Free shipping is displayed alongside flat rates and other available shipping methods even if the customer is qualified for free shipping.

Therefore, to enhance the shopping cart experience for customers and prevent confusion, it’s beneficial to automatically hide other shipping methods when free shipping is available in WooCommerce.

Below code snippet instructs WooCommerce to hide other shipping methods when free shipping is available.

 * 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 maverick_hide_other_shipping_when_free_shipping_is_available($rates, $package)
    $free_shipping = array();
    // Loop through available rates
    foreach ($rates as $rate_id => $rate) {
        // Check if free shipping is available
        if ('free_shipping' === $rate->method_id) {
            $free_shipping[$rate_id] = $rate;
            break; // Exit loop when free shipping is found

    // Return only free shipping if available
    return !empty($free_shipping) ? $free_shipping : $rates;
add_filter('woocommerce_package_rates', 'maverick_hide_other_shipping_when_free_shipping_is_available', 100, 2);

Benefits of Automatically Hiding Other Shipping Methods when ‘Free Shipping’ is Available in WooCommerce

  1. Improved User Experience: Automatically displaying only the free shipping option simplifies the checkout process for customers.
  2. Reduced Confusion: Customers won’t be confused by multiple shipping options when free shipping is available.
  3. Streamlined Checkout: A single shipping option speeds up the checkout process, potentially reducing cart abandonment rates.

Leave a Reply

Your email address will not be published. Required fields are marked *