// Hide Local Delivery shipping method if cart less than $25 add_filter( 'woocommerce_package_rates', 'fivetwelve_hide_delivery_based_on_subtotal', 10, 2 ); function fivetwelve_hide_delivery_based_on_subtotal( $rates, $package ) { // Get the current cart total $cart_subtotal = $package['contents_cost']; // Set the shipping class for ineligible products $shipping_class_target = 45; // shipping class ID $in_cart = false; // Check the shipping class of each product in the cart foreach( WC()->cart->get_cart_contents() as $key => $values ) { if( $values[ 'data' ]->get_shipping_class_id() == $shipping_class_target ) { $in_cart = true; break; } } // If the cart total is less than $25, or // a product exists with the ineligible shipping class, // remove the local delivery shipping method if( $cart_subtotal < 25 || $in_cart ) unset( $rates[ 'szbd-shipping-method:10' ] ); return $rates; }