Hide add to cart button for guest users for a particular category

hi so i wanted to know how i can hide both the price and add to cart button for a particular product category for guest users.

please if anyone can help

Hey @Singh,

Please give us the URL of your category page and also a screenshot of the area you’re referring to maybe it could be achieved using simple CSS so we could help you with that.

Thanks.

Hi @christian_y ,
No actually i wanted to use functions in child theme to achieve this.
So when guests see a particular category say cat1 the add to cart and price should not be visible but it should be visible when logged in. but in the case of cat2 the price and add to cart should be shown for any users.

is this possible ??

thanks

Hi Singh,

Yes this is possible but not through the functions.php file,

You will have to override the Woocommerce template which you can do in the child theme.

Please check this link for more info:

The files you could check out are in: woocommerce/templates

Then you will have to add a condition to check if the user is logged in or not and the category as well.

The simpler option would be to add some custom CSS as what @christian_y suggested. Wordpress has a class indicator on the page if the user is logged or not and the categories as well.

Hope this helps you get started.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.