Created
March 22, 2022 11:54
-
-
Save wpflames/aaeb31cc4b03edc84e544c8a9711309b to your computer and use it in GitHub Desktop.
Unset Specific Shipping Methods if Free Shipping is Available
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // ========================================================================= | |
| // Unset Specific Shipping Method if Free Shipping is Available | |
| // ========================================================================= | |
| function unset_shipping_when_free_is_available_in_zone( $rates, $package ) { | |
| // Only unset rates if free_shipping is available | |
| if ( isset( $rates['free_shipping:8'] ) ) { | |
| unset( $rates['flat_rate:1'] ); | |
| } | |
| return $rates; | |
| } | |
| add_filter( 'woocommerce_package_rates', 'unset_shipping_when_free_is_available_in_zone', 9999, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment