How to Hide Price and add to cart to non-register members in Woocommerce

In this tutorial we’ll learn how to hide the prices and add to cart button to non-registered members. The process is simple enough we can achieve this by using one of woocommerce’s defined filter and by imposing a check to add that filter.

Initially the shop and single product page will look something like this:

woocommercewoocommerceHere add to cart button and prices are visible.

Now, if you place the following lines of code at the end of functions.php it will enable the desired functionality.



if(is_user_logged_in() ){

return $price;


else return '<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '">Login</a> or <a href="'.site_url('/wp-login.php?action=register&redirect_to=' . get_permalink()).'">Register</a> to see price!';


You can find the functions.php file here:

woocommerceNow, place the code save the file and refresh your page.

You’ll see the add to cart button and prices removed and it will add login and register links instead.

Now your shop page and single product page will look something like this.


That is it!


I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

Leave a Comment

Your email address will not be published. Required fields are marked *