This custom code will support the free shipping method and will hide other delivery methods if the cart is more than 250 , and if the goods are not heavy (less than 20 kg here) ... To prevent free shipping for orders less than 250, you can set this in woocommerce (see end).
First you will need to make sure that the weight is set in each heavy product (for simple or variable products (in each option). Percentage of the basket Excluding taxes (and you can change it including taxes easily.)

Then this custom function got caught in the woocommerce_package_rates filter:
add_filter( 'woocommerce_package_rates', 'conditionally_hide_other_shipping_based_on_items_weight', 100, 1 ); function conditionally_hide_other_shipping_based_on_items_weight( $rates ) { // Set HERE your targeted weight (here is 20 kg) <== <== <== <== <== $target_product_weight = 20; // Set HERE your targeted cart amount (here is 250) <== <== <== <== <== $target_cart_amount = 250; // For cart subtotal amount EXCLUDING TAXES WC()->cart->subtotal_ex_tax >= $target_cart_amount ? $passed = true : $passed = false ; // For cart subtotal amount INCLUDING TAXES (replace by this): // WC()->cart->subtotal >= $target_cart_amount ? $passed = true : $passed = false ; // Iterating trough cart items to get the weight for each item foreach(WC()->cart->get_cart() as $cart_item){ if( $cart_item['variation_id'] > 0) $item_id = $cart_item['variation_id']; else $item_id = $cart_item['product_id']; // Getting the product weight $product_weight = get_post_meta( $item_id , '_weight', true); if( !empty($product_weight) && $product_weight >= $target_cart_amount ){ $light_products_only = false; break; } else $light_products_only = true; } // If 'free_shipping' method is available and if products are not heavy // and cart amout up to the target limit, we hide other methods $free = array(); foreach ( $rates as $rate_id => $rate ) { if ( 'free_shipping' === $rate->method_id && $passed && $light_products_only ) { $free[ $rate_id ] = $rate; break; } } return ! empty( $free ) ? $free : $rates; }
The code goes in the function.php file of your active child theme (or theme), as well as in any plug-in file.
This code has been tested and works for simple and variable products ...
You will also need to specify the minimum order amount in the WooCommerce> Delivery settings for each delivery zone and for the "Free Shipping" method:

You need to update the cached delivery data: disable, save and enable, save the associated delivery methods for the current delivery zone in the woocommerce delivery settings.
source share