To hide all other shipping methods when free shipping is available 2.0

To hide all other shipping methods when free shipping is available 2.0

October 21, 2024 | Mashiur Rahman

To hide all other shipping methods when free shipping is available

How to Hide All Shipping Methods When Free Shipping is Available in WooCommerce

Shipping plays a crucial role in the customer’s purchase decision. Offering free shipping can significantly reduce cart abandonment and enhance user experience. However, when both free and paid shipping options are displayed at checkout, it can confuse customers and may lead them to question which option is better. To avoid this confusion, many online store owners prefer to hide all shipping methods when free shipping is available.

If you’re running a WooCommerce store and want to automatically hide all other shipping methods when free shipping is available, you’re in the right place. In this tutorial, I’ll show you how to achieve this using a simple snippet of code that you can add to your theme’s functions.php file.

Why Hide Other Shipping Methods?

Before diving into the solution, let’s first understand why you might want to hide other shipping methods when free shipping is available:

  1. Reduce Confusion for Customers: Displaying multiple shipping options, especially when free shipping is available, can confuse customers. They might wonder why there are paid options when free shipping is also listed.
  2. Improve Checkout Experience: A streamlined checkout process encourages faster decision-making. Fewer distractions lead to fewer abandoned carts.
  3. Boost Sales Conversions: By highlighting free shipping as the primary or only available option, customers may feel they’re getting a better deal, which can lead to higher conversion rates.

Now, let’s get started with the solution.

Step-by-Step Guide to Hiding Other Shipping Methods

This method involves adding a custom function to your functions.php file, which is part of your theme. When free shipping is available for a customer’s cart, the function will automatically hide all other shipping options.

1. Access Your WordPress Theme’s Functions File

To access the functions.php file, follow these steps:

  • Log in to your WordPress dashboard.
  • Navigate to Appearance > Theme File Editor.
  • On the right-hand side, you’ll see a list of theme files. Scroll down and select Theme Functions (functions.php).

2. Add the Custom Code to Hide Shipping Methods

Next, add the following code to your functions.php file:

php
add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 100, 2 );

function hide_shipping_when_free_is_available( $rates, $package ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
if ( ‘free_shipping’ === $rate->method_id ) {
$free[ $rate_id ] = $rate;
break;
}
}
return !empty( $free ) ? $free : $rates;
}

This code works by filtering the available shipping methods. It loops through all available shipping options and checks if free shipping is available. If it detects free shipping, it hides all other shipping methods and shows only the free shipping option.

3. Save the Changes

After adding the code, scroll down and click the Update File button to save your changes.

4. Test the Changes

It’s essential to test your checkout process after implementing the code. Add items to your cart and proceed to checkout to see if only free shipping is displayed when it’s available.

How the Code Works

 

Let’s break down the code to understand what it does:

  • The woocommerce_package_rates filter allows us to modify the available shipping methods in WooCommerce.
  • The function hide_shipping_when_free_is_available runs through the list of shipping methods and checks if free_shipping is available.
  • If it finds free shipping, it creates an array containing only the free shipping method.
  • Finally, it returns either the free shipping method (if available) or all available shipping methods (if free shipping is not applicable).

When to Use This Solution

 

This solution is perfect for stores that regularly offer free shipping based on certain conditions, such as:

  • Cart total threshold (e.g., free shipping for orders over $50).
  • Coupon code-based free shipping.
  • Location-based free shipping.

By implementing this, you ensure that your customers are presented with a simple and clean shipping option that enhances their buying experience.

Things to Keep in Mind

 

  • Backup First: Always create a backup of your functions.php file before making any changes. This ensures that you can restore your site if anything goes wrong.
  • Child Theme: If you’re working with a theme that gets regular updates, consider creating a child theme and adding the code there. This will prevent your changes from being overwritten during theme updates.

Final Thoughts

 

Offering free shipping is a proven strategy to boost sales, but it’s essential to ensure the checkout process remains straightforward. Hiding other shipping methods when free shipping is available helps avoid confusion and creates a more seamless experience for your customers.

By following this simple method, you can improve your WooCommerce store’s user experience and increase conversions with just a few lines of code.

More update

&

Click Here

Leave a Reply

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

Share This Post:

Share Your Feedback

Select Pro Services *
Your Name *
Country *
Review (0 to 5) *
Review Description *

Made by
Add Your Heading Text Here
From: April 9, 2025
By Referral Only

ByReferralOnly.com is an online training and marketing platform designed for real estate agents and mortgage professionals. Founded by Joe Stumpf, it focuses on helping service providers grow their business through client referrals. The platform offers virtual courses, templates, and marketing tools to build strong, relationship-based businesses.

Price Range
$200-$300
Project Duration
4-7-days
By-Referral-Only-Home-Page-1-Joe-Stumpf-s-By-Referral-Only
Skills and expertise
Elementor
WordPress
Responsive Design
Page Speed Optimization
From: February 19, 2025
naturalaquascaping.com

NaturalAquascaping is here for all of your aquarium-creating needs. Find the best aquarium plants, filters, and more, plus in-depth reviews and guides

Price Range
$200-$300
Project Duration
1-3-days
Natural Aquascaping - WELCOME AQUARIUM LOVER
Skills and expertise
Elementor
WordPress
From: March 17, 2024
Portfolio

This is my personal portfolio website showcasing my skills in WordPress design and development. It includes examples of past projects, services I offer, and a contact section for potential clients. The site is optimized for performance and responsive on all devices.

Price Range
Not available
Project Duration
1-2-weeks
admin
Skills and expertise
Elementor
WordPress
Responsive Design
From: October 16, 2024
Landing Page

This is a custom-designed landing page for a dog food brand. It features an eye-catching hero section, product highlights, customer testimonials, and a strong call-to-action to boost conversions. Fully responsive and optimized for performance

Price Range
$50-$100
Project Duration
1-3-days
just-another-WordPress-site-scaled-e1729709380372.webp
Skills and expertise
Elementor
WordPress
From: November 30, 2022
Next Level IT

We are a leading Managed Security Services Provider with Experience-Based leadership and professional IT process consulting resources to help you achieve your IT and Cyber service improvement and business objectives.

Price Range
$200-$500
Project Duration
1-3-days
Next-Level-IT-–-Professional-IT-Consulting-Services-1-scaled.webp
Skills and expertise
Elementor
WordPress
From: January 31, 2024
Villa

Villa village Manastira – a corner of paradise in the Trojan Balkan. Here you will feel homely comfort and peace

Price Range
$200-$500
Project Duration
1-3-days
Вилно-селище-Манастира-Троян-scaled.webp
Skills and expertise
Elementor
WordPress
From: January 1, 2024
KOLLAGEN.LIFE

Buy marine collagen, peptide and collagen hydrolysate, a convenient way to purchase collagen in the online store.

Price Range
$200-$500
Project Duration
4-7-days
Buy-collagen-sale-of-collagen-purchase-collagen-online-store-kollagen-life-scaled.web
Skills and expertise
Elementor
WordPress
WooCommerce
From: January 1, 2024
Dental

Welcome to Maple Dental Centre, we are an established dental Practice in Roehampton, London, for over 40 years. The current Practice owner and principal is Dr. Hamid Ghods.

Price Range
$200-$300
Project Duration
1-3-days
https://mapledentalcentre.co.uk/
Skills and expertise
Elementor
WordPress
WordPress Security
From: November 4, 2023
Jigya Software

Leading software development company in Hyderabad, India. Experts in custom software, mobile, and web development etc.

Price Range
$200-$500
Project Duration
1-3-days
https://www.jigya.com/
Skills and expertise
Elementor
WordPress
From: September 3, 2024
Bandeira & Associados

A Bandeira e Associados é uma empresa especializada em serviços de consultoria e assessoria com mais de 20 anos no mercado.

Price Range
$200-$300
Project Duration
1-3-days
Bandeira-Associados
Skills and expertise
Elementor
WordPress
From: March 5, 2024
M&S

At M&S Capacitaciones we identify ourselves as being an academy focused on training people in the field of private security in Colombia. We have different headquarters nationwide as well as highly qualified personnel to meet the requirements demanded by the Superintendency of Surveillance and Private Security.

Price Range
Project Duration
https://myscapacitaciones.com/
Skills and expertise
From: June 5, 2024
Golf seats

El Tigre crafts bespoke Custom Golf Cart Seats, blending luxury and functionality. Elevate your game with personalized comfort on the green.

Price Range
Project Duration
golfseats.com
Skills and expertise
Scroll to Top