Woocommerce – Hide other shipping methods if free shipping is available not work
-
im adding the following code and it’s working perfectly but when im adding more than two products it’s not working and it brings me all the possible shipping methods. Once i’m adding only one product again it brings the right shipping method.
add_filter( 'woocommerce_package_rates', 'cssigniter_hide_other_methods_when_free_shipping_is_available', 100 ); function cssigniter_hide_other_methods_when_free_shipping_is_available( $rates ) { $free = array(); foreach ( $rates as $rate_id => $rate ) { if ( 'free_shipping' === $rate->method_id ) { $free[ $rate_id ] = $rate; break; } } return ! empty( $free ) ? $free : $rates; }
The page I need help with: [log in to see the link]
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Woocommerce – Hide other shipping methods if free shipping is available not work’ is closed to new replies.