Your cart is currently empty!
Restrict purchase of product to group but show whole product to all
—
by
Is there a programmatic way to hide the “buy button” to users of a group but show the rest of the content to all visitors? We are using Groups and Groups WooCommerce, but it appears we can only hide or show the entire listing, not just restrict access to actual purchase (we know this can be done with Woo Memberships, but need to use Groups due to another integration that is exclusive to Groups)
Posted in Groups
Comments
One response to “Restrict purchase of product to group but show whole product to all”
Hi Jill,
The easiest way to check the user for a given group is Groups_User_Group::read( $user_id, $group_id ). If the user doesn’t belong to a group, then don’t show the add to cart button.
Regarding WC an interesting method for this is is_purchasable(), but the tricky part resides to the fact that you should add the group conditional to all types of product templates and to the product catalog.
I haven’t tried it myself but this is how I would implement it.
Kind regards,
George