hide add to cart for a user role and product category
-
Hello Team,
I would like to disable the ‘Add to cart’ button when a user with role ‘Retailer’ opens a product category page.
Could you please help on below?
/* * Disable add to cart button based on different user roles */ $categories = array('Bags','SHOP'); $allowed_user_roles = array('Retailer'); $user = wp_get_current_user(); if( array_intersect( $allowed_user_roles, $user->roles ) ) { if( has_term( $categories, 'product_cat', $product->get_id() ) ) { return false; } return $is_purchasable; }
Thanks,
Roshan
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘hide add to cart for a user role and product category’ is closed to new replies.