Please consider leaving a donation if you appreciate this information. Lightning network now available
WooCommerce and many of its extensions are highly customizable. WooCommerce Memberships is certainly included in the list of highly customizable extensions. As an example – suppose a merchant is selling products that grant access to a memberships plan and once a purchase of one of those products has been made, the merchant doesn’t want to show that product to members. How can this be done? It starts with the WooCommerce provided product visibility filter named appropriately woocommerce_product_is_visible – as of WooCommerce version 2.6.4 that filter can be seen here.
With that in mind, a custom snippet can be crafted to set the return value of that filter to false if the current user is a member of a plan that a particular product grants access to. Please note that this will only affect logged-in users. If the viewer is a member but not logged-in, they will see the product. This code snippet is an example of how this can be achieved:
Not sure what to do with code snippets? See What Do I Do With These Code Snippets?
Please consider leaving a donation if you appreciate this information. Lightning network now available
Leave a Reply
You must be registered and logged in to post a comment.