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? 1 How to Hide Free Shipping When Subtotal is Greater Than 0 in WooCommerce?](https://media.tychesoftwares.com/wp-content/uploads/Hide-Shipping-Method-when-the-subtotal-is-greater-than-0-1024x690.png)
Moreover, you can also hide WooCommerce shipping methods for certain conditions including to hide free shipping until the order total is greater than $250.