• Resolved theslymovement

    (@theslymovement)


    I have a list of products which should be visible to anyone who browse my woocommerce site and to regular customers who are logged in. Also I have a special category of customers who are logged in and are assigned a specific role. Is it possible to hide some of the products that are available to general public from the users that are in specific role?

    Example (Assuming that I have products A,B, C, D, E, F):
    General public/browsing – can see products A, B, C
    Customers after logged in – can see products A, B, C
    Customers in a special group role – can see only products D, E, F

    So far I’ve figured out how to allow visibility based on role but not how to hide visibility. Is it possible at all?
    Would appreciate any help/directions

    https://www.ads-software.com/plugins/woocommerce/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    Thread Starter theslymovement

    (@theslymovement)

    Thank you Mike

    I’ve seen a number of solutions where I can allow access to a product only for a member of a specific group but I need an opposite – to deny access to a product for a member of a group. At the same time general public who are not a member of any group should still have an access.

    Happy to write custom code if someone could point me to right direction…

    Plugin Contributor Mike Jolley

    (@mikejolley)

    At the same time general public who are not a member of any group should still have an access.

    Whats to stop the user logging out to see them? Sounds backwards to me..

    Thread Starter theslymovement

    (@theslymovement)

    Totally agree with you, probably it is backwards but unfortunately it is a user requirement and I can’t change it.

    I think I have to resort to custom coding, do you know which WooCommerce hook should I use to hook the filter which will be called once per product so that I can get user membership/capabilities and prevent product to be displayed in the catalogue?

    Plugin Contributor Mike Jolley

    (@mikejolley)

    unfortunately it is a user requirement and I can’t change it.

    Is your user aware people could logout to view those products :p?

    There are 2 methods; 1. Using a pre_get_posts filter. This will keep products per page and pagination working.

    2. woocommerce_product_is_visible filter. This can hide on display but products per page may be wrong if hiding something.

    Thread Starter theslymovement

    (@theslymovement)

    haha yes, but they are still insisting on it.

    That’s great! thanks so much for your help!

    I need exactly this too! Have you managed to find a way to do this? I’ve been trying for weeks.

    Our scenario is that we have a product (let’s call it A) unregistered users can purchase, but a logged in user would get an equivalent product (B) but it’s with a different product code. Both A and B look the same, but they are handled differently in the back office processing (e.g. they have different prices, B is delivered in multiples of 6 only, from a separate warehouse, and has a different in-stock quantity from A, while A can be ordered as singles and will be shipped from a different location).

    Any help very much appreciated!

    Hi! You can use the WooCommerce Products Visibility plugin.

    This plugin hides the selected products, categories and tags for each user role (it even has a guest role for unregistered user) from your whole website , eg. from the menus, the widgets and even from the theme you use, as long as the theme is using WordPress filters.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘restricting access to products’ is closed to new replies.