Skip to content

Instantly share code, notes, and snippets.

@WPprodigy
Created March 31, 2016 21:36
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