Skip to content
Advertisement

Woocommerce: hide category in shop

I have a category with products not visible to everyone. I already have a script in place, that removes this category from the sidebar widget, when no items in the category are visible to the user.

I created a function that puts the exclude term_id in a global variable. Now I need something that excludes them from view in the shop.

JavaScript

However, in the shop view itself, the category is still visible. How can I remove it there, when no items in this category are visible to the user.

I have tried: https://gist.github.com/rynaldos/a9d357b1e3791afd9bea48833ff95994 But it removes the category ALWAYS, in both widget and shop.

Products are being displayed by group membership of the customer: https://wordpress.org/plugins/groups/

Advertisement

Answer

I think I managed to create a script that made this possible: https://gist.github.com/DarkAllMan/cffb114eb97c6f26882e54793e023587

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement