Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Checks if the customer is a reseller and
* returns false if they are trying to purchase from a specific category.
* @param bool $is_purchasable If the product is purchasable or not.
* @return bool
function limit_purchases_by_role( $is_purchasable, $product ) {
$categories = $product->get_category_ids();
if ( current_user_can( 'resell_product' ) && in_array( 17, $categories ) ) {
return false;
return $is_purchasable;
add_filter( 'woocommerce_is_purchasable', 'limit_purchases_by_role', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.