Created
November 18, 2020 13:21
-
-
Save gaelbillon/b4d5e915a06a3db31a15fd75568394a5 to your computer and use it in GitHub Desktop.
Forbid free shipping (with plugin Advanced Free Shipping ) for Woocomerce Membership members
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
// Forbid free shipping for members on any Woocomerce membership plan plan | |
add_filter( 'woocommerce_package_rates', 'filter_woocommerce_package_rates', 10, 2 ); | |
function filter_woocommerce_package_rates( $rates, $package ) { | |
if ( function_exists( 'wc_memberships' ) ) { | |
if ( wc_memberships_is_user_member() ) { | |
foreach ( $rates as $rate_key => $rate ) { | |
if ( 'advanced_free_shipping' === $rate->method_id ) { | |
unset($rates[$rate_key]); | |
return $rates; | |
} | |
} | |
} | |
} | |
return $rates; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment