skip to Main Content

Search WordPress Code Snippets – Quick Solutions for Developers


How to Hide Shipping Method Based on Cart Total in WooCommerce

This snippet allows you to hide specific shipping methods when the cart total falls below a certain amount.

add_filter('woocommerce_package_rates', 'hide_shipping_method_based_on_total', 10, 2);
function hide_shipping_method_based_on_total($rates, $package) {
    if (WC()->cart->subtotal < 50) { // Change 50 to your desired threshold
        unset($rates['flat_rate']); // Replace 'flat_rate' with your shipping method ID
    }
    return $rates;
}

I’m a WordPress developer with 10+ years of experience in WooCommerce and custom plugins. I combine technical expertise with design flair to help you create standout, user-friendly websites. Let’s transform your digital presence!

Back To Top