Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Hide Free Shipping When Subtotal is Greater Than 0 in WooCommerce?

If you wish to hide the “Free Shipping” option on your cart page based on the cart subtotal, the following code snippet will help you achieve this objective.

function ts_filter_woocommerce_package_rates( $rates, $package ) {
    // Get subtotal
    $subtotal = $package['cart_subtotal'];
    
    // Hide free shipping if subtotal > 0
    if ( $subtotal > 0 ) {
        // Loop through rates
        foreach ( $rates as $rate_id => $rate ) {
            // Check if it is the free shipping method
            if ( 'free_shipping' === $rate->method_id ) {
                // Remove the free shipping method
                unset( $rates[$rate_id] );
            }
        }   
    }
    return $rates;
}
add_filter( 'woocommerce_package_rates', 'ts_filter_woocommerce_package_rates', 10, 2 );

Output

When the cart subtotal is greater than 0 in the WooCommerce cart page, the “Free Shipping” shipping option is hidden.

How to Hide Free Shipping When Subtotal is Greater Than 0 in WooCommerce?

Moreover, you can also hide WooCommerce shipping methods for certain conditions including to hide free shipping until the order total is greater than $250.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x