Code-Snippets-Functions/Execute a function on a child site/WooCommerce/exclude-shipping-method-from-specific-user-role.txt

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;
}