Created
March 31, 2016 21:36
-
-
Save WPprodigy/c39c3cd4fb8068eab0eb0133459f75c8 to your computer and use it in GitHub Desktop.
Hide a shipping method based on a use role
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
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