Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hide a shipping method based on a use role
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
You can’t perform that action at this time.