Created
March 31, 2016 21:36
Hide a shipping method based on a use role
This file contains 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
function wc_ninja_role_base_shipping_method( $rates, $package ) { | |
// Make sure flat rate is available | |
if ( isset( $rates['flat_rate'] ) && ! current_user_can( 'wholesale' ) ) { | |
unset($rates['flat_rate']); | |
} | |
return $rates; | |
} | |
add_filter( 'woocommerce_package_rates', 'wc_ninja_role_base_shipping_method', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment