Disable 'Flat Rate' shipping method when 'Weight Country' is available in cart
-
Hello,
I hope someone could help about the below issue.
I try to adapt the below function but it seems that it does not work:
/** * woocommerce_package_rates is a 2.1+ hook */ add_filter( 'woocommerce_package_rates', 'hide_flat_rate_when_wf_country_weight_woocommerce_shipping_is_available', 10, 2 ); /** * Hide flat rate when country weight shipping is available * * @param array $rates Array of rates found for the package * @param array $package The package array/object being shipped * @return array of modified rates */ function hide_flat_rate_when_wf_country_weight_woocommerce_shipping_is_available( $rates, $package ) { // Only modify rates if free_shipping is present if ( isset( $rates['flat_rate'] ) && isset($rates['wf_country_weight_woocommerce_shipping']) ) { // To unset a single rate/method, do the following. This example unsets flat_rate shipping unset( $rates['flat_rate'] ); } return $rates; }
When both methods are available for checkout, the ‘Flat Rate’ one has to be hidden.
I use specific shipping classes in the ‘Flat Rate method.
Thank you for your help!!
https://www.ads-software.com/plugins/weight-country-woocommerce-shipping/
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Disable 'Flat Rate' shipping method when 'Weight Country' is available in cart’ is closed to new replies.