2

What's the best way to set up a flat rate shipping fee up to a certain dollar amount, and then free shipping over that dollar amount? I'd like to set it up like this: $15 shipping for all items in their cart if cart is less than $50, free shipping on orders over $50. Thanks!

Jason
  • 545
  • 1
  • 4
  • 10
  • May be this Question code + Answer can put you on the right way (even if is not really the same problem): http://stackoverflow.com/questions/42396787/shipping-calculated-on-the-items-weight-and-cart-amount – LoicTheAztec Mar 03 '17 at 03:40

1 Answers1

0

You can achieve this with following way

  • Config the flat rate in WooCommerce zone
  • Config the Free shipping with minimum order amount $50
  • Use below code snippet to hide Flate rate if the cart total is above $50

    add_filter('woocommerce_package_rates', 'hide_flat_rate_based_on_cart_total', 10, 3);
    function hide_flat_rate_based_on_cart_total( $available_shipping_methods, $package ){
        $price_limit = 50;
        if( WC()->cart->get_total() > $price_limit ){
            foreach($available_shipping_methods as $method_key  =>  $method){
                if ( strpos($method->method_id, 'flat_rate' ) !== false) {
                    unset($available_shipping_methods[$method_key]);
                }
            }
        }
        return $available_shipping_methods;
    }
    
Nishad Up
  • 3,457
  • 1
  • 28
  • 32