mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://www.businessbloomer.com/woocommerce-exclude-shipping-method-from-specific-user-role/
8 lines
318 B
Text
8 lines
318 B
Text
add_filter( 'woocommerce_package_rates', 'wc_disable_shipping_rate_user_role', 9999, 2 );
|
|
|
|
function wc_disable_shipping_rate_user_role( $rates, $package ) {
|
|
if ( wc_current_user_has_role( 'customer' ) ) {
|
|
if ( isset( $rates['flat_rate:5'] ) ) unset( $rates['flat_rate:5'] );
|
|
}
|
|
return $rates;
|
|
}
|