I'm currently working to create a wholesale option through woocommerce. I have the wholesale infrastructure down when you are logged in and have the user role "wholesale_customer". However I'm one step away from finishing and I can't figure it out.
I want to offer local delivery for our in town wholesale customers and that's it; not customers or guest users. Currently we have a usps plugin that offers shipping for the customers and guest purchases.
Here is currently what I have, I fee like I'm close, just missing a few things. Anyone have any suggestions?
function wholesale_local_delivery( $available_methods ) {
global $woocommerce;
if ( isset( $available_methods['local_delivery'] ) ) {
if (current_user_can('wholesale_customer')) {
unset( $available_methods['local_delivery'] );
}
}
return $available_methods;
}
add_filter( 'woocommerce_available_shipping_methods', 'wholesale_local_delivery' );
P.S. I know I could purchase the Woocommerce plugin but I don't want to do that.
current_user_can doesn't check the role, it checks permissions which I don't think is what you want. Try this: