WooCommerce: Hide Price & Add to Cart for Logged Out Users

You may want to force users to login in order to see prices and add products to cart.

All you need is pasting the following code in your functions.php (please note: your theme may have overwritten some default WooCommerce functions, hence the code below may not work. Contact me if you need custom code). Enjoy!

WooCommerce: Hide Price & Add to Cart to Logged Out Users

PHP Snippet: hide add to cart and price if logged out @ WooCommerce Shop & Single Product Page

 * @snippet       Hide Price & Add to Cart for Logged Out Users
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @sourcecode    https://businessbloomer.com/?p=299
 * @compatible    WooCommerce 3.6.2
 * @donate $9     https://businessbloomer.com/bloomer-armada/
add_action( 'init', 'bbloomer_hide_price_add_cart_not_logged_in' );
function bbloomer_hide_price_add_cart_not_logged_in() {   
if ( ! is_user_logged_in() ) {      
 remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
 remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
 remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
 remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );   
 add_action( 'woocommerce_single_product_summary', 'bbloomer_print_login_to_see', 31 );
 add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_print_login_to_see', 11 );
function bbloomer_print_login_to_see() {
echo '<a href="' . get_permalink(wc_get_page_id('myaccount')) . '">' . __('Login to see prices', 'theme_name') . '</a>';

Where to add this code?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such delicate files - if you need more guidance, please take a look at my free WooCommerce Customization video tutorial.

Does this snippet still work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free videos, tutorials and tips!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP
  • woocommerce-customize-shop-page-PHP
  • woocommerce-advanced-customization
  • how-to-edit-woocommerce-cart
  • woocommerce-customize-checkout-page-PHP
  • woocommerce-email-customization
  • woocommerce-conditional-logic

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

283 thoughts on “WooCommerce: Hide Price & Add to Cart for Logged Out Users

  1. Hello,

    Is it possible to make the text wrapped as a button? It would be better from an UE perspective.

    Kind regards,

    1. Hi Petar, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  2. I see you revised this code in May 2019. Your code states it @compatible WooCommerce 3.6.2.

    I am currently installing Version 5.2.1

    Is your code compatible with the most recent version of WP?

    1. Yes of course

  3. Hi Rodolfo Melogli,

    Your work is appreciated, but I have a problem, I am using Pecil theme. I add your code in functions.php file, I don’t have child theme. but it just hiding Prices but not add to cart button from product pages before login. I tried on default theme too but no change. So please can you guide me what I need to do for hiding add to cart button before login. I am looking forward for your response.

    Best Regards,

    1. Hi Raj, thanks so much for your comment! I just retested this on the latest version of WooCommerce and it still works. Unfortunately this looks like custom troubleshooting work and I cannot help here via the blog comments. Thanks a lot for your understanding! ~R

  4. Hi,
    This code was working fine for a year but Now today its not working on only one product category page, it is working on rest of the pages. Dont know what to do , can you help?

    1. Hello Ajay, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?

      To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.

      Hope this helps!


  5. Hi, for me is working, for visitors, but google is showing prices in his images directory in mobiles phones.

    How can I fix that, because, is a very big problem.

    1. Hello Adriana, thanks so much for your comment! Yes, this is possible – unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  6. Unfortunately code is not working for me in a brand new fresh WordPress install. I can still see prices although it says “login to see prices” below the price. Here’s my setup:

    WordPress 5.0.3
    Woocommerce 3.5.4
    PHP 7

    1. Hey Ed, thanks for your comment! Can you try switching temporarily to “Twentyseventeen” or “Storefront” theme and let me know if it works?

  7. TYVM!! This works great 2/5/2019

    1. Cool!

  8. Hi Rodolfo,

    I have a similar issue to the one Felix has, when I activate the plug in I get:

    Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at wp-content/plugins/hide-price-until-login/includes/hide-price-until-login-class.php:540) in wp-content/plugins/hide-price-until-login/includes/main.php on line 7

    Warning: Cannot modify header information – headers already sent by (output started at wp-content/plugins/hide-price-until-login/includes/hide-price-until-login-class.php:540) in wp-admin/includes/misc.php on line 1126

    Not sure what to do…
    thanks for your help

    1. Hey Annelie, thanks for your comment. You’re using another plugin, and that does not relate to my snippet πŸ™‚

  9. Thanks a lot! It still works in 2018 with Divi theme, Woocommerce and Ultimate Member.
    I was using a plugin to hide the price (called ‘Hide Price Until Login’ by CedCommerce) but it gave me some white screens of death, so I had to delete it. And then I found your piece of code and it works great.

    1. Awesome πŸ™‚

  10. Hi Rodolfo,

    the snippet worked perfectly until a few days ago. I think it might be the woocommerce update 3.4.7 where something went wrong.
    Just to let you know, and perhaps you might be able to fix it πŸ˜‰

    Thanks a lot,


    1. Georg, thanks for your comment! I don’t see 3.4.7 changes that might affect this snippet. Can you try with another theme please?

  11. Is there any way to make this snippet work with YITH WooCommerce Wishlist as well? This works perfectly with hiding pricing but users are able to click add to wishlist then see the pricing in that screen.

    1. Dear Ben – thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  12. Hi, Rodolfo. I’am using your snippet, but I use also plugin β€œVariations to Table – Grid”. Effect: The price of the main product is hidden, but in the table of variable products prices are still visible. How to hide prices in the table of variable products until login? How to modify your snippet? Is this possible?

    1. Hello Maciej, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  13. Hi Rodolfo.
    I am using this snippet and it worked great after the set up a year ago. But now logged in customers can no longer see the Buy button or cart, they only get the “Login to see the price”. This problem also appears with latest version of WC. I made a test order in an incognito window before updating WC, and it is still there.
    I also use your snippet for privacy policy (https://businessbloomer.com/?p=19854). Do they conflict?
    Best regards

    1. Hello Johan! No, they should not conflict – but if you want to test this feel free to disable the privacy snippet and see if the error goes away. In regard to this snippet, it is still valid and it works. Maybe something changed in your theme – can you try to switch theme temporarily to see if the snippet works with e.g. 2017 theme?

  14. Hi Rodolfo,

    I implemented this super nice piece of code, sadly it doesn’t hide my button on the Shop loop. I didn’t use many snippets yet and tried to turn some things around like setting the final value to 50 to see if it had any effect, without success.
    Let’s also mention that I use the clever Code snippets plugin to do the hard job without braking my site.

    Do you have a quick fix idea ?

    1. Hi Rodolfo, I finally found the issue. Since I use the Divi theme & builder I had to add a specific snippet to allow Woocommerce to display its “add to cart” button. It’s a shame we have to add this (non given) snippet while seeing that it even bring some limitations as this one.

      Here is the snippet in question :

      function dac_add_cart_button ()
          add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 10 );
      add_action( 'after_setup_theme', 'dac_add_cart_button' );

      Here is the modified version to work only for logged-in users :

      // register add to cart action
      function dac_add_cart_button ()
       	if ( is_user_logged_in() )
          add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 10 );
      add_action( 'after_setup_theme', 'dac_add_cart_button' );

      Removing the dedicated code as this :

      /* Hide Price &amp; Add to Cart for LOGGED OUT USERS + show text :  "Login to see prices" */
      add_action( 'init' , 'woo_hide_price_and_button_not_logged_in' ); 
      function woo_hide_price_and_button_not_logged_in()
      	if ( !is_user_logged_in() )
      //	remove_action( 'woocommerce_single_product_summary' , 'woocommerce_template_single_add_to_cart' , 30 );  Related to Divi button setup php
      	remove_action( 'woocommerce_single_product_summary' , 'woocommerce_template_single_price' , 10 );
      	remove_action( 'woocommerce_after_shop_loop_item' , 'woocommerce_template_loop_add_to_cart' , 10 );
      	remove_action( 'woocommerce_after_shop_loop_item_title' , 'woocommerce_template_loop_price' , 10 );
      	add_action( 'woocommerce_single_product_summary' , 'woo_print_login_to_see' , 31 );
      	add_action( 'woocommerce_after_shop_loop_item' , 'woo_print_login_to_see' , 11 );
      function woo_print_login_to_see()
      	echo '<a href="' . get_permalink(wc_get_page_id( 'myaccount' )) . '" rel="nofollow">' .
      	__( 'Afficher les prix' , 'theme_name' ) . '</a>' ;

      But I would rather include the original snippet into yours to understand how to add any other snippet that would work conditionally to hide the “add to cart” button.

      Here is my trial but lead to block my WP site :

      add_action( 'init' , 'woo_hide_price_and_button_not_logged_in' ); 
      function woo_hide_price_and_button_not_logged_in()
      	if ( !is_user_logged_in() )
      function dac_add_cart_button ()
          remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 10 );
      add_action( 'after_setup_theme', 'dac_add_cart_button' );
      	remove_action( 'woocommerce_after_shop_loop_item' , 'woocommerce_template_loop_add_to_cart' , 10 );
      	remove_action( 'woocommerce_after_shop_loop_item_title' , 'woocommerce_template_loop_price' , 10 );
      	add_action( 'woocommerce_single_product_summary' , 'woo_print_login_to_see' , 31 );
      	add_action( 'woocommerce_after_shop_loop_item' , 'woo_print_login_to_see' , 11 );
      function woo_print_login_to_see()
      	echo '<a href="' . get_permalink(wc_get_page_id( 'myaccount' )) . '" rel="nofollow">' .
      	__( 'Afficher les prix' , 'theme_name' ) . '</a>' ;

      It seem in deed that including a function into another didn’t work. If you could leed me on a good path it would be so great.

      Best regards and thanks for your great work.

    2. Hello there, thanks so much for your comment! Unfortunately this looks like custom troubleshooting work and I cannot help here via the blog comments. Thanks a lot for your understanding! ~R

  15. Still works, thanks a lot !

    1. Awesome πŸ™‚

  16. Thank you very much Rodolfo, it works perfectly. Fantastic job!

    1. Thanks Sinisa πŸ™‚

  17. Nice Code Rodolfo,

    Quick question – While this hides the options on the product pages for non-logged in users does it also hide the prices from Google image search results that show products.

    Google still seems to be picking this up? Visible from a mobile search in Google images.


    1. Hey Gary, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  18. Hi,

    Thank you for sharing this code! You’re the man!

    I have two quick questions?

    #1. Is there a way to have the variable options visible? Example: Size (dropdown)

    #2. Is there a way to display two different messages?

    A custom message on the shop page?
    A custom message on the single product page?

    1. Hey Ryan, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  19. Hi! After update to 3.3.4 something changed and none of these 3 variations seems to work. Can’t figure out what seems to be causing problem. As release notes dont show any changes related to these.

    1. Hey Michael, thanks so much for your comment! I just retested it on 3.3.4 and it works perfectly – sorry πŸ™‚

  20. Hello, Can you give me the code in plugin form. Your code works but the requirement is to add a plugin of it

    1. I can’t, sorry Kalyani πŸ™‚

  21. I use the divi theme and the woo layout injector plugin to customize the product pages. The code doesn’t seem to work on the custom pages I made with the plug in but it works on the normal woocommerce pages. Can you help me_

    1. Enrique, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  22. Hello, this works great, however I have a “featured” products section on my home page that still displays the prices. Is there a snippet that could hide that as well? Thank you!

    1. It seems to be working perfect now! : )

  23. Hi Rodolfo

    What about hiding price and add to cart for a specific category (or categoris)?
    So that specific products can not be purchased before registration but other products can.


  24. Hey

    It works for the simple product. But fro virtual product it shows add to cart button.

    1. Hey Harsh thanks for your comment! I just tried snippet #1 on WooCommerce 3.1.2. with a virtual product and it works. Please test with a different theme as that could be the reason why πŸ™‚

  25. Hi ,

    Thank you for this. It has removed “Add to Cart” button and when hovered “login to see prices” comes up which is great but the price attached to the product does not get hidden ( when not hovered) . I want to hide price too. How do i do it?

    Many thanks,

    1. Kumar, thanks so much for your comment! Unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  26. Nice code, thanks. Is there a chance to enable the price for the related products on the product detail site?

  27. Your code works great for the price! Unfortunately, I’m unable to get the β€œadd to cart” to be removed. Is there a reason for this? I placed the snippet of code directly into my functions.php file.

  28. Hi..

    Tried all of them but not changed. Also disabled guest checkout.

    Using Woocommerce 3.0.5 with Php 5.6.25

    1. I see. Sorry, but this must be because of your custom theme/plugins. Check previous comments and you will possibly find a way to troubleshoot. Let me know πŸ™‚

  29. Fantastic. Thank you. Snippet 3 did it for me!

    1. Thanks a million Rob!

    2. hello Rodolfo,
      I used snippet #2 and it worked. I don’t know why now in some product items appear the price. In the source code it is this statement:

      €0,00 / 1 StΓΌck

      May be there was a change in relation with the recent Woocommerce updates ?!?
      Any idea ?
      Thanks a lot !

    3. sorry, PHP:

      span class="wgm-info price-per-unit price-per-unit-loop ppu-variation-wrap"><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">&euro;</span>0,00</span> / 1 StΓΌck</span> 


    4. funny, just solved the prob:
      as “regular price” (0,00) there was “1” / per piece…….. there mustn’t be any number ! πŸ˜‰

    5. Cool, glad I waited before replying πŸ˜€ Thank you Felix!

  30. Hi Rodolfo,

    Your code works great for the price! Unfortunately, I’m unable to get the “add to cart” to be removed. Is there a reason for this? I placed the snippet of code directly into my functions.php file.

    1. My apologies just saw the previous comment from Michael.

    2. Excellent πŸ™‚ Keep me updated. If you find a custom code for your custom theme, I can add it here. Let me know

  31. Hi Rodolfo

    I added your functions and they worked for hiding prices but my add_to_cart buttons are still working. If unregistered customer pushes that buttons he can see his checkout process and all price in his basket πŸ™‚
    Should I change any other thing ?
    Thanks for your support.

  32. Thank you Rodolfo for these snippets. I tried out #1 and #2 but i still see the button “add to cart”. Could you give me a tip?

    1. Hi Michael, thanks for your comment! It could be that your theme is overriding the default WooCommerce add to cart and therefore my functions won’t work and will need to be customized. Unfortunately this is custom work and I cannot provide a complementary solution here on the blog. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  33. Hello,
    which function .php should I add them for hiding price? In woocommerce pluging folder?


    1. Hey Hasan, you can place this in your child theme’s functions.php file – if you need more guidance, please take a look at this video tutorial: https://businessbloomer.com/woocommerce-customization-hangout/. Hope this helps!

    2. thanks for reply, I try with child them didnot worked but when I changed default function .php is working properly πŸ™‚ so what is the differences between both function page?

      by the way its not working with the items in best seller, top rated or Featured tab. Is there something that hiding price also from this area?


    3. Hey Hasan, thanks for your comment! If it works in the parent but not on the child theme, there is something wrong with your child theme – it should work there. In regard to the other issue, I can’t tell, as probably those are generated by your custom theme and my function would need to be edited to make it compatible to your specific situation πŸ™‚ Thanks for your understanding!

  34. hello Rodolfo, Thanks for all your tips !
    After putting in any of the snippets I always get these error messages:

    Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w01555d9/shop.dessousundmode.com/wp-includes/functions.php:1) in /www/htdocs/w01555d9/shop.xyz.com/wp-includes/pluggable.php on line 893

    Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w01555d9/shop.dessousundmode.com/wp-includes/functions.php:1) in /www/htdocs/w01555d9/shop.xyz.com/wp-includes/pluggable.php on line 894

    I already looked for this error, seems like a syntax error………
    Can you give an advice? Thanks so much. Best regards Felix

    1. Hey Felix, thanks for your comment! If it was a syntax error it would show in the error log, while you’re getting the “headers already sent” error instead. I would try to re-write your whole functions.php from your FTP (delete the one you have, create a new one, paste the code), and see if it makes any difference. Let me know! πŸ™‚

    2. thanks Rodolfo, I just did it, without succes……….. πŸ™
      I must try another way…

    3. Strange πŸ™‚ If you add a random snippet do you get the same error?

  35. hii,

    I want to disable some product price . This price show only when user login. and also add to cart disable button when user not logged such product.

    1. Hey Sandeep, thanks for your comment! You can probably make use of “conditional logic” and only trigger my snippet when a certain condition related to your “special products” is met. Try taking a look here: https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/

  36. Hi.

    When I apply the code, snippet #1, by variable products it does now show the dropdown, hence not letting me see other variations of the products. Is there a way to fix this so I can see all variations of the products while having the price hidden?

    Thank you.

    1. Chaim, thanks for your comment! Yes, of course that is possible – unfortunately this is custom work and I cannot provide a complementary solution here on the blog. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  37. Thanks a lot, you snippet helped so much

    1. Brilliant, thanks so much for your feedback Lucas!

  38. Hi Rodolfo,
    Like your website and thanks for helping.
    I have used your snippet and adjusted to my theme and is working great but i’m not sure if i wrote it correctly can you please advice.

    add_action('after_setup_theme', 'bbloomer_hide_price_add_cart_not_logged_in');
    function bbloomer_hide_price_add_cart_not_logged_in()
        if (!is_user_logged_in()) {
             add_action('woocommerce_single_product_summary', 'flatsome_catalog_mode_product', -99);
             add_action('woocommerce_single_product_lightbox_summary', 'flatsome_catalog_mode_lightbox', -99);
             add_filter('woocommerce_is_purchasable', 'flatsome_woocommerce_is_purchasable', 10, 2);
             remove_action('woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20);
             remove_action('flatsome_product_box_actions', 'flatsome_product_box_actions_add_to_cart', 1);
             add_filter( 'body_class', 'flatsome_body_classes_catalog_mode' );
        }else {
             remove_action('woocommerce_single_product_summary', 'flatsome_catalog_mode_product', -99);
             remove_action('woocommerce_single_product_lightbox_summary', 'flatsome_catalog_mode_lightbox', -99);
             remove_filter('woocommerce_is_purchasable', 'flatsome_woocommerce_is_purchasable', 10, 2);
             add_action('woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20);
             add_action('flatsome_product_box_actions', 'flatsome_product_box_actions_add_to_cart', 1);
             remove_filter( 'body_class', 'flatsome_body_classes_catalog_mode' );
    1. Hello Malchaz, thanks for your comment! Unfortunately I don’t use Flatsome theme so I have no idea – have you tried asking their support team?

  39. Hi Rodolfo!

    Thanks so much for this awesome snippet.
    We’re using it (V2.5.5) to hide prices and add to cart for logged out users.

    I have a quick question:
    Is it possible to ‘disable’ the function for a certain category please?
    Ie. Products of a certain category are excluded from this function, meaning they always show price and add to cart?

    We have products (in category with ID ’65’) that will be available to anyone, logged in or not – and we need to modify your function for this purpose.

    Any help would be hugely appreciated.
    And thanks again for this and all your useful info!

    1. Just wanted to clarify/summarize my previous question:

      1. Products in Category ‘specials’ must be available to add to cart and show pricing to everyone (logged in or logged out users)
      2. Everything else requires log in to add to cart or view prices.

      So far we have successfully used your code to hide add to cart and pricing from anyone who is not logged in. We are working on excluding that one category from the function (or any other more elegant solution you may have!!)

      Thanks again, really appreciate it.

    2. Yes – that’s correct! You’re on the right track πŸ™‚

    3. Thanks for the feedback Rodolfo,

      What we would need to know exactly is how to exclude that one category (say ID ’65’) from this function altogether please?

      So that one category would be excluded.

    4. Hey, thanks so much for your feedback! Yes, this is possible – but unfortunately this is custom work and I cannot provide this solution on the blog right now.

      If you would like to get a quote, feel free to go here.

      Thank you for your understanding!


  40. Hi,

    The product image not showing for logged out users in woocommerce single product summary page. it is a variable product and have added the below code for logged out users. it is showing correctly for loggedin users.if it is a simple product it works fine.


    1. Annie, there is a CSS fix that has been around for a few months as many were getting the same problem – and it’s not related to this PHP snippet in particular. Try use:

      /* CSS to show product images @ single product page */
      .product.has-default-attributes.has-children > .images {
          opacity: 1 !important;

      Let me know πŸ™‚

  41. Hi – thanks for the snippet. My theme developers have tried to help me but we are now stuck. I have tried all versions of the snippet but it is hiding the variant selection drop downs. I have selected default variant and everything else works.

    1. Brett, thanks a lot for your feedback! I’m not entirely sure I understand your issue – this snippet hides the variation select box as long as I’m aware? Let me know! πŸ™‚

    2. Hi Rodolfo,

      Thank you very much for sharing your code with in depth support for it.

      With variable product, I like to show visitors all the attributes but not the price except login users. ( by removing the 2nd remove_actions of your script)

      The ‘add to cart button’ was disabled when there is no options selected for the variable product or there is no stock for the product.

      I was wondering if there is a quick way to either move the “add to cart” button(keeping the options or attributes) or disable it (faking no-login-users with zero stock maybe?)

      Thanks in advance,


    3. Hey Bob thanks for your comment! I’m not entirely sure your workaround would be the best way to proceed. What if you had a little PHP snippet that said “if product is variable, echo attributes as text”, without having to fake another solution?

    4. Ideally the non-logged in user should be able to view variants but not the prices. I need the variant drop downs to remain.

    5. In order to do that, you should look into the function “woocommerce_variable_add_to_cart()”. At some stage you will find a specific add_action for single variations. Therefore, try removing the add to cart by using:

      remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );

      Let me know

  42. Sir
    u have sown us to hide price and add to cart for non logged users can it be done like until login it should say ” login to download ” once logged in
    in same place it should allow to download .

    1. and also pls tell where to insert the code u have showed here

    2. Thank you Anand. You can place this in your child theme’s functions.php file – if you need more guidance, please take a look at this video tutorial: “How to Customize WooCommerce with PHP Snippets (even if you don’t know PHP)“. Hope this helps!

    3. Anand, thank you for your comment. I’m afraid the “download” thing is not a WooCommerce default functionality, so this is a custom project that I can only help with if I have full access to your code and study your specifications. Sorry but I can’t help this time πŸ™‚

  43. Is there a way to only show the prices and add-to-cart button for specific logged-in user roles?

    1. Hey John, thanks for your comment! Of course there is – take a look at what I’ve done here (different goal, yet you will understand the “user role” thing): https://businessbloomer.com/disable-payment-gateway-specific-user-role-woocommerce/

      Let me know πŸ™‚

    2. Hello

      Your code works fine on the product page but on the home page add to cart button is still there and instead of printing a text its totally blank.

    3. Hey Junior, thanks for your message!

      I’m afraid my code only works on the shop, category and single product pages – it won’t work on the homepage I believe. You also have something custom there (the products look different from your shop page, are you using a shortcode or something like that?).

      I believe to fix this you will need custom coding, specific to your theme or custom homepage.

      Hope this helps!


  44. Hey Rodolfo,
    I know this is not relevant to this particular article, but I was wondering if you have a visual hook guide for the checkout/ order received page?

    1. Hey Choco, yes, totally off topic πŸ™‚ Nah, just kidding! Yes, you can find the checkout visual hook guide here. In relation to the thank you page, it has only 2 hooks:

      do_action( 'woocommerce_thankyou_' . $order->payment_method, $order->id )
      do_action( 'woocommerce_thankyou', $order->id )

      Hope this helps!

  45. Hello,

    How can I remove only add to cart for not registered customers ? They are allowed to see prices.

    Thanks for your help.

    Frank Blokzijl

    1. Hello Frank, and thanks for your comment! All you need is removing these 2 lines:

      remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
       remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );

      Let me know if it works πŸ™‚

  46. Hey Rodolfo Melogli

    Thanks for this amazing solution and your awesome “how to” videos! – Helped me ALOT!

    I have one question though..

    I canΒ΄t seem to change the “login to see price” text? – Maybe you can help me πŸ™‚


    1. seems like i figured it out myself! πŸ˜€

    2. Ahah SΓΈren excellent! Thanks a lot for your comments πŸ™‚

    3. Hmmm.. Seems i was wrong :/

      I can control text when im on the specific product page.

      But the button is still visible when your are on the page where you can see all products.. – I hope i make sense.

      Here is a link: http://www.vetcur.dk/produkter-2/

    4. And it removes the play button from my video i seems :/

    5. The function adds the same content to both the single product page and the “loop” page (where all products are). If you want a different message you need to split my snippet into 2:

       * @snippet       Hide Price & Add to Cart for Logged Out Users @ Single Page
      add_action('init', 'bbloomer_hide_price_add_cart_not_logged_in_single');
      function bbloomer_hide_price_add_cart_not_logged_in_single() {	
      if ( !is_user_logged_in() ) {		
       remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
       remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
       add_action( 'woocommerce_single_product_summary', 'bbloomer_print_login_to_see_single', 31 );
      function bbloomer_print_login_to_see_single() {
      echo '<a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">' . __('Login to see prices', 'theme_name') . '</a>';


       * @snippet       Hide Price & Add to Cart for Logged Out Users @ Loop
      add_action('init', 'bbloomer_hide_price_add_cart_not_logged_in_loop');
      function bbloomer_hide_price_add_cart_not_logged_in_loop() {	
      if ( !is_user_logged_in() ) {		
       remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
       remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );	
       add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_print_login_to_see_loop', 11 );
      function bbloomer_print_login_to_see_loop() {
      echo '<a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">' . __('Login to see prices', 'theme_name') . '</a>';

      Let me know πŸ™‚

  47. Hi Rodolfo, first tanks for all your work, since i started with WordPress your tutorials and codes where very helpful, iΒ΄ve the code and it works perfect.

    The only thing is when they preview the product o better say when they do a “quick view” in Flatsome the button for add to the cart shows and when they use it, they can see the price in the carshop.

    1. Francisco, thanks a lot for your message! I’m afraid my code works on a default installation of WooCommerce only. Your theme (Flatsome) is adding the “Quick View” functionality and therefore additional code will be necessary to remove the add to cart from there.

      You should search through the Flatsome theme PHP files for the function that creates the Quick View, then in some way remove it if users are not logged in.

      Unfortunately I don’t own the Flatsome theme and I don’t offer complementary snippet customisation. If you need technical help and you would like to get a quote for the fix, feel free to go here to get in touch.

      Thanks for your understanding!


    2. Tnks for your answer, I decided yo disable the quick view! Tnks for your code – I will continue using.

    3. Awesome, thanks for letting me know Francisco πŸ™‚

  48. Hi Rodolfo,

    I implemented your script and it hides the prices….However it also hides the QUANTITY.
    And I need that filed to enable a visitor to request a quote.

    Do you have a solution that ONLY hides the ADD to Cart-Button??|


    1. Hey Bram, thanks for your comment!

      Yes, this snippet hides the add to cart and therefore the quantity as well – not sure having the quantity without the add to cart is necessary πŸ™‚

      Do you have specific requirements? Let me know!

  49. Hi there. This sounds like the solution I have been looking for. Where do I place this code to get this to work? I’m new with this.



    1. Thank you Hollianne. You can place this in your child theme’s functions.php file – if you need more guidance, please take a look at this video tutorial: “How to Customize WooCommerce with PHP Snippets (even if you don’t know PHP)“. Hope this helps!

  50. Hi,

    Thanks for trying to help me in the Facebook group.
    Sad so say the help did not do much good for me.

    Will gladly send you login details + ftp login if you can assist me here.

    Best regards,

    1. Thank you Johan – I’ll see what I can do πŸ™‚ Please email me your details at info[AT]businessbloomer.com, thank you!

    2. Does the script handle attributes?

    3. You’re right, your WooCommerce CSS was also hiding images if the Add to Cart button was not present on variable products. I sent you the fix and also posted a brand new version of the snippet (#1) that should now work with all themes and all plugins.

      Glad I was able to help, and thanks for sharing your FTP details!

      Talk soon πŸ™‚

  51. Hi,

    I tried your code on top of this page under: Hide add to cart & prices + show β€œLogin to See Prices” instead

    I am using Generatepress as theme. I added the code at the end of functions.php but no result, the price does not disappear.

    Could you help me out?


    1. Hey Michiel, thanks for your comment! I strongly recommend not to edit your theme core files. You should build a child theme and place all your customization there. If you want to test the snippet you can alternatively use the free WP plugin called “Code Snippets”: download it, add a new snippet, place my PHP in there and see if it works. Let me know!

  52. Hi Rodolfo!

    First of all i would like to thank you for your help. I use your snippet and it works. But unfortunately the “add to cart” buttons are hidden for only 1 item and the rest of it still shows it. I use Flatsome theme and my website is drspiller.id. Could you check it up? I really count on you πŸ˜‰

    1. Hey Chico, thanks for your comment! Have you tried both snippets or only one? Someone had the same problem and switching to the other worked for them. Thanks πŸ™‚

    2. Hello Rodolfo! The second one works better. Its hidding all the product prices. but the add to cart button are still showing up.. did i missing something? A very big thanks should i say πŸ™‚

    3. Awesome πŸ™‚ Re: add to cart, it could be that a plugin or theme is customizing that part already (remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 );) and therefore you need to investigate further. Hope this helps!

    4. Hey rodolfo!Thanks a lot for your script.I am facing a tiny problem.Some of my variable products have different prices.When you go on the product page it says Login to see prices but if you select variables then is shows the different prices.Maybe i have to include an extra line to your code?

    5. Hey Mike, you’re welcome! So, the line:

      remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

      will remove the variation select box as well (on a default WooCommerce theme). Probably your theme or developer have customized something and my code is not removing what it should πŸ™‚

      Please investigate and if you can’t manage to fix it feel free to get in touch.


    6. Hey Rodolfo,I tried your other scripts and it worked better!!Thanks a lot!But another problem appeard.On the product page it wont show the product image.Is there anything i can do to fix that?Thanks again!

    7. That’s awesome Mike! Re: product image, I’m not sure. Can you give me a link so I can take a look?

    8. I send you a personal e-mail.Thanks a lot in advance Rodolfo!

    9. Thank you Mike, I’ve seen this problem before with variable products.

      Try adding this to your style.css:

      /* CSS to show product images @ single product page */
      .product.has-default-attributes.has-children > .images {
          opacity: 1 !important;
    10. Thanks a lot Rodolfo – it works!

    11. You’re welcome πŸ™‚

    12. Hey again Rodolfo!
      I am facing again after months a tiny problem…Whenever i add a button to a page it wont show it unless i am logged in…I believe it has to do with this script cause in the visibility of the button i have it to say “Always visible”.Can you give me a hand?

    13. Mike, thanks for your comment. If you disable the script does your “button” show? It’s difficult to help you without a screenshot or URL – let me know πŸ™‚

  53. Hi Rodolfo

    Interesting code, what about hide the price of selected products?

    1. Thanks for your comment Alain! In regard to your query, that’s an interesting one I must say – when you say “selected products” do you mean “products in the cart”?

  54. Hi

    I tried the code above (to hide prices unless logged in) in a PHP snippet, but it hides every page on the website when the function.php file is uploaded to the child theme folder.
    Is there something i’m missing or should i take it this code wont work with my theme?

    If its conflicting with the theme, do you know which files i should look at to try and edit?

    1. Hey Olly, thanks so much for your comment! This is weird, it works like a charm on WooCommerce 2.5.5 and Storefront theme. This should be placed in your child theme’s functions.php.

      Try switching theme and check if it works. If not, disable ALL plugins but WooCommerce and see if it works. In this case, you can then reactivate one plugin at a time to see which one is causing the conflict.

      Hope this helps πŸ™‚

  55. Hi Rodolfo, thanks for your snippet. As some user, i have Avada theme and i can confirm your snippet don’t remove or hide “Add to cart” in single product page, and prices are showed in cart/checkout.

    If i’ll find some workaround will update you.


    1. Thank you Riccardo for letting me know that πŸ™‚ You can either Dropbox me the Avada files, or otherwise make a search for “woocommerce_single_product_summary” in the Avada files and let me know what results you get πŸ™‚

  56. Hi Rodolfo,

    Sorry for wasting your wall, but I just fixed it myself.

    Very simple fix but not easy to figure out…

    Solution just choose a default variation on the product then everything loads perfect!

    Take care.

    – Mathias

    1. Awesome Mathias, glad to hear that πŸ™‚ Keep in touch!

  57. Hi Rodolfo Melogli,

    First of all thanks for all the great code! I am a huge fan!

    I have just used your code for a page I am making for a friend. Everything in the code is working perfect except for one thing. Whenever I have a variable product the images do not show up… you can still click on them and then they show up just fine. The weird thing is that it does work fine on simple products.

    Variable product:

    Simple product:

    I really hope you can help me out I have tried everything I can think of.


    – Mathias

    1. Mathias, thanks for your comment – much appreciated πŸ™‚ Are you sure that my code causes this? If you disable my code does the image show? Thank you! ~R

    2. Thx for the code, but I have the same problem that Mathias Nielsen had. Images not showing. If I remove your code it is working. With the code, images only show on product page if clicked. Some how Mathias Nielsen has fix the problem, but didn’t show how. Can you help?

    3. Hey Mese, thanks for your comment! Are you having problems with variable products?

    4. Yes. Just variable products the images aren’t showing up.

    5. Take a look at his second reply – he explained there what the solution was for him. I will double check on my test website as well in the meanwhile! Thanks πŸ™‚

    6. Oh, sorry I overlooked his reply. Thank you for the great and fast support! I don’t know why but it’s working with the default variation…

    7. Awesome πŸ™‚ No problem at all, you’re welcome!

    8. Hi Mathias,
      Can you let me know how you have fixed this issue?. i am also having the same issue.
      Thanks & Regards,

  58. Hi rodolfo, I use this code and it hide the pricing in products and shop, but add to cart still showing with the pricing.

    1. Thanks for your feedback Muhammad! Can you give me your website link and also send me a screenshot? Thank you!

  59. Any reason why the New code only displays the message for the first item like here: https://www.toritako.com/product-category/flags-banners/animals/birds-animals-amp-other-critters and the ‘old’ code displays it correctly beneath every product, but when you into the product it still shows my variations and prices.

    For now I have stuck with the New code and just dealing with the fact that it’s only shown on the first product.

    1. Thanks Chris for your feedback! It’s not the first time this happens to be honest. I will take a look at the code and revert if I can πŸ™‚

    2. I just updated the snippet – this new version should work! πŸ™‚

  60. I tried your updated code on the mystile theme, but nothing happened. All prices and ‘add to cart’ button still there.
    Has anybody done this with the mystile theme?


    1. Hey Christof, thanks for your feedback! I just tried the “alternative PHP snippet” (the second one on the blog page) on a Mystile test website and it works perfectly – try again πŸ™‚

    2. Hello Rodolfo.

      I’m afraid I have to admit it’s a matter of RTFM… or something similar for your blogs.

      My mistake is that I added it to the functions.php of the theme. Since the theme probably already does some magic, the code didn’t work.
      That’s exactly why you repeat probably 10 times in your ‘How to Customize WooCommerce with PHP Snippets‘ video tutorial that one should NEVER EDIT YOUR THEME but always edit a child theme.

      So I created the child theme according to the simple wordpress.org instructions, then added your code to that functions.php… et voila!

      My appologies for not having figured this out immediately. But I thought to write down this info here again, just in case someone else needs it.

      Thanks for the help/code!


    3. Awesome πŸ™‚ Love your comment lol!!!

  61. This is great! Thanks!
    I was curious, my theme (MediaCenter) adds custom taxonomy for “brands”. Do you know how I could only hide prices for certain brands or at least where I should look to figure out how to filter them? Or, is there a way to easily filter using a custom field check box for each product and variation? Thanks for the help!

    theme: http://themeforest.net/item/mediacenter-electronics-store-woocommerce-theme/9177409

    1. Chase, thanks for your comment πŸ™‚ In this case, you’ll need to ask your theme developers – you paid for it so they should be able to give you support! Otherwise, go look into the PHP files and see if you can identify anything that might help. Hope this is of any use πŸ™‚ ~R

    2. Okay thanks, I will check.
      I guess I was hoping there was a generic way to check a custom taxonomy like your solution for checking categories:

      if (is_product_category( β€˜shirts’ )) {
      // do something

    3. Oh yes, there is definitely something like that! You can try using:

      /* change 'category_slug' with your Category Slug */
      /* do not edit 'product_cat' */
      if ( has_term( 'category_slug', 'product_cat' ) ) {
      // do something
    4. That worked! Thanks, I did need a slight tweek:

      if ( has_term( ‘brand-slug’, ‘product_brand’ )

      I’m having another issues that is odd but I think this is a theme issue. You can see in the picture (http://oi66.tinypic.com/wbb712.jpg) that the prices are removed but the text that replaces the prices is only shown the first time. In the list view, it works right, only in the block view does this happen.

      Thanks again!

    5. Chase, thanks for your comment πŸ™‚ In relation to the other issue, that’s pretty strange. Have you tried using the second snippet instead?

    6. yeah, i tried but no good.
      It’s very odd. The prices are cleared but after the first time the “new” price or text is displayed nothing is displayed after that only on the Grid view, the list view works just great. I’ve reached out to the theme creator to see if they know why. It’s just odd.

    7. Odd πŸ™‚ A previous commenter found out this code only works in a child theme. I take you’re already using it?

    8. The Theme author is looking at it for me to see why it’s not working and to make the fix.
      Currently I am using a child theme though.

    9. Thank you Chase, keep us updated πŸ™‚

    10. Chase, I just updated the snippet – this new version should work! πŸ™‚

    1. You’re welcome Pablo! De nada πŸ™‚

  62. Thanks for this post. The code has unfortunately stopped working! Do you have a replacement code?

    1. Tdang, thanks for your message! This snippet works on my test website so I find it unusual that it stopped working. Was it working before on your website? What did you do recently (updated theme / plugin)? Thank you

  63. I have tried this code. Its working But It seems like showing old content after logged in. For example, If unlogged user views a page which does not display the price details. Once he logged in then he click the same page again but It does not show price this time. When he refreshes the page, It shows the price. I have tried wc3 total cache plugin. Still struggling to address the issue. Please help

    1. Hello Ismail, thanks for this! I think this is an issue with your cache plugin, my snippet is not cache-friendly! If you remove W3TC, does the problem still occur?

  64. Hi and thanks for this code. I was wondering if there is a way to show only discounted prices to unlogged users?

    1. Reel, thanks for your feedback. I’m sure there is a way to do this but I’m afraid this is pretty custom and I’m very busy this week! Maybe I’ll create a post about this soon. R

    2. Hello Rodolfo,

      Thanks for the code.

      The snippet seems to hide my prices for both listed and single products, but the only issue I’m having is that my prices still show up in my cart (without being logged in). How can I remove his feature so people can only view the cart when logged in?

      I am using the theme ‘thefox’

      and here is my website link http://aceminiatures.co.uk/

      Thanks in advance

    3. Hello Alex, thanks for your comment! To hide prices in the cart it’s a bit more complicated, as you will need to inspect in the WooCommerce PHP templates all the places where prices are generated. Question – if you hide the add to cart with my snippet – how can your users add to cart?

  65. First, thanks for this code. Looks awesome! I have 2 things:

    1. I am using the avada theme. On the page that displays all the products from that category, only the first product returns the link to login. Prices do get hidden though so thats good. Any idea why only one product would return that? All the single product pages are fine.

    2. Any way to only hide prices from one category? I have 2 divisions of my business and want to show pricing for one and hide prices for the other.


    1. Josh thanks so much for your feedback. It’s possible that Avada theme is already overriding those filters and actions and therefore my snippet conflicts with your theme. I’m afraid I can’t provide the fix for you here as it is custom work.

      In relation to only hiding prices for one category, of course. You can use WooCommerce conditional rules to establish if you’re on a specific category page, and say e.g.

      if (is_product_category( ‘shirts’ )) {
      // do something

      , where 12 is your category ID.

      Hope this helps!

    2. Thank you for the response. I am trying to make it work with your not logged in feature. I.e i want users NOT logged in to see category B’s prices and return the “login to see prices” for category A. Users logged in OR logged out to see category A and B. I used this statement

      // Hide prices

      add_action(‘after_setup_theme’,’activate_filter’) ;

      function activate_filter(){
      add_filter(‘woocommerce_get_price_html’, ‘show_price_logged’);

      function show_price_logged($price){
      if(is_product_category( β€˜B’ )){
      return $price;
      elseif (is_user_logged_in() ) {

      return $price;

      remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’ );
      remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );
      remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );
      remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 );
      return ‘‘ . __(‘Login to see prices’, ‘theme_name’) . ‘‘;

      If they are not logged in, it does not use the category conditional statement. It just hides all prices.

      Thank you for the help!!

    3. Sorry, one mistake in my last comment: I do not want users logged in or out to see prices from products in categories A and B. It should be:

      Logged in: See prices from products in category A and B

      Logged out: see prices from products in category B. Return “login to see prices” for products in category A.

      Thank you!

    4. There is something wrong in your if…else statements. In my opinion you should just use a simple if:

      if (!is_user_logged_in() && is_product_category( ‘A’ )) {
      // run function if user is not logged in and category is “A”

    5. I tried that. I also tried replacing && with ||, but the is_user_logged_in() part seems to be the dominate function. Using this if statement, it will just hide all the prices if the user is logged out. It does not show prices for one of the categories when the user is logged out like I want.

    6. I was able to sort out my issue by using the has_term function. the is_product_category was not working. I am using this code which works for pages that only have 1 category on them. It works for pages with multiple categories but does not display the add to cart button for the product that you want to show prices and add to cart for when you are logged out.

      // Hide prices

      add_action( ‘after_setup_theme’,’activate_filter’) ;

      function activate_filter(){

      add_filter(‘woocommerce_get_price_html’, ‘show_price_logged’);


      function show_price_logged($price){

      if (is_user_logged_in()) {

      return $price;


      if( has_term( ‘moisturetint’, ‘product_cat’) ) {

      return $price;

      remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’ );
      remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );

      return ‘‘ . __(‘login to see prices’, ‘theme_name’) . ‘‘;

      remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );

      remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 );



    7. Awesome Josh, thanks for your feedback!

  66. Hallo…. I used storefront theme with germanized plugin and have the same problem as Micheal

    1. I add this code to disabled single price:

      remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_gzd_template_single_price_unit’ );

    2. Thomas, thank you for this!

  67. Hi,

    This article is great and helped me understand a bit more what I’m trying to do, but I could just use some advice if possible.

    I’m using a third party theme (woopress) and my customer requires that the cart widget, add to cart and prices etc are hidden from non logged in users.

    Using your code I managed to hide prices, but the top cart widget in the header is still visible.

    I asked them for guidance and got nowhere, but I HAVE noticed that there’s a ‘catalog’ mode included in the theme, and I’ve found it in the theme functions file. Could you help me tweak it so that when the catalog mode is enabled, it only affects users that aren’t logged in?

    The code I’ve found is:

    // **********************************************************************//
    // ! Catalog Mode
    // **********************************************************************//

    function etheme_remove_loop_button(){
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
    remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
    remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
    remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
    remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );

    add_action( 'after_setup_theme', 'et_catalog_setup', 18 );

    if(!function_exists('et_catalog_setup')) {
    function et_catalog_setup() {
    $just_catalog = etheme_get_option('just_catalog');

    if($just_catalog) {

    Thanks in advance!

    1. Hey David, thanks for this. You could simply use “if(!is_user_logged_in() )” (which means “if the user is not logged in”) before the call:

      if($just_catalog && !is_user_logged_in()) {

      Let me know πŸ™‚

    2. Hi Rodolfo,

      It worked almost perfectly. When I enable catalog mode it now hides prices for logged out users, but shows them for logged in users.

      The only problem I’ve found is that enabling catalog mode hides the cart in the header of the site, so I just need to work out how to make sure that always shows for logged in users, and I think I’ve nailed it ! πŸ™‚

    3. Great David! Thanks for your feedback πŸ™‚

  68. Hi Rodolfo,

    I would like to add the “login/register to see prices” on all of product boxes, not just the first one on the page.

    can you help me add this?


    1. Michael, thanks for your inquiry. To me, this looks like there is a conflict between your plugins or alternatively your theme has already customised the hooks and filters I used in my snippet. Maybe investigate a little further as this snippet works on almost all websites. Let me know!

    2. Not quite sure what you mean? the theme has customized your hooks and filters?

    3. Apologies Michael for not explaining well.

      In this snippet we use, for example, this:

      remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 )

      Now, this is giving for granted that your website has:

      add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 )

      …which for standard themes will be there. However, if your theme developers have already worked on that particular hook, and say did something like:

      remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 )
      add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 56 )

      …(note the 56 at the end of the add_action), once we apply the following, it won;t work:

      remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 )

      So, you have to make sure that your template is not overriding those hooks already.

      Hope this makes sense!


    4. I had same issue using Avada theme. I solved this by rearranging the else statement as follows:

      remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’ );
      remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );

      return ‘‘ . __(‘login to see prices’, ‘theme_name’) . ‘‘;

      remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );

      remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 ); }

      *Notice the return is in the middle of the 4 remove_actions

  69. β€˜.__(β€˜Login to see prices’, β€˜theme_name’).’ i mean inside the a tag

    1. Awesome, fair play, thanks so much!

  70. this doesnt work with WPML.
    but this:

    return ‘‘.__(‘Login to see prices’, ‘theme_name’).’‘;

    Works perfect

  71. Hi how can i make the Login to see prices translatable.

    1. TB, thanks for your question! Just use “< ?php _e( 'Login to See Prices', 'my-text-domain' ); ?>” (I also updated the code in the snippet, thanks for this!)

  72. We also want to remove price from logged out users, only logged in users may see the products prices. I used your given new code by just pasted it in themes function.php. It returned the page with your code written on it. I need your help in this regard. I am novice in woocommerce and PHP, Please provide me step by step guide.

    1. Hey Vaseem, thanks for your feedback! Did you paste the code at the bottom of your template’s functions.php file?

  73. the box of price

    1. I would like to hide the box surrounding the price, which is still visible
      thx πŸ™‚

  74. yes I have this code:

    #product-box {
      display: none;

    But it hides in all categories …
    This is possible only in certain category ?

    1. Yes Fred, how many categories do you need that for? Do you have the category IDs?

    2. I just need to hide in one category. No there is no ID but links …
      here’s the category where I want to hide the box: {…}

      thx in advance πŸ™‚

    3. I don’t see the element you want to hide on that page. There are no prices?

  75. Hello, is it possible to hide the box of the price? (product box) in a category ?

    I find it but it hides the price and not the box …

    thanks πŸ™‚

    1. Fred, yes this is possible. You will need to add some CSS to the PHP function to ask the system to display:none whatever element you’re trying to hide. Feel free to get in touch if you need a hand. R

  76. Dear Rodofil Melogi,

    Thanks for your code. But I need to disable prices everywhere including for all users. As our store will have bulk orders we want our users to have add to cart(for quotation) functionality but prices will be fixed after negotiations. Is there a way to remove prices from shop as well as cart and check out pages?

    Thanks in advance

    1. Arth, thanks for your feedback. I think you should take a look at this plugin, it hides all the prices everywhere and instead it puts a “quotation” button: WooCommerce Email Inquiry & Cart Options

  77. Hi how do I hide the “add to cart” button only for specific products? I wish to keep the price there but just hide the button only for individual products.

    Thank you

    1. Thanks for your enquiry! In order to apply any PHP to a specific product, simply use is_single(ID) where ID is the product ID. Hope this helps!

  78. Thanks so much for this!

    Need it for our wholesale store. Much appreciated.

    1. Thank you Josh! Your feedback is much appreciated as well πŸ™‚

  79. can you give me the contact information I can send you to your FTP account edit

    1. Sure, just go here and use the contact form or my email address πŸ™‚ Thank you

  80. I did like your guidance but faulty

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘activate_filter’ not found or invalid function name in public_html/wp/wp-includes/plugin.php on line 496

    1. Sorry, I don’t really understand what you mean – can you explain again please? πŸ™‚

  81. i also wish to do the same in my…I want to hide price and add to cart from general public and only for people with accounts. I tried the these and the price is gone, and it says (logged users only) but the add to cart button is still there. So if a non logged in users go to the site it says log in to view price but when they add to cart the price shows up. Please help me with this, been trying for about a week now, i haven’t been able to find a solution.

    1. found it in “content_single_product”

      * @hooked woocommerce_template_single_add_to_cart – 40

    2. Cool – then remove that action:

      remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 40 );

    3. do i add that i function.php or bring content_single_product file into child theme?

    4. Sorry, it wasn’t clear πŸ™‚

      Use this in your functions.php:

      // Hide prices
      add_action('after_setup_theme','activate_filter') ;
      function activate_filter(){
      add_filter('woocommerce_get_price_html', 'show_price_logged');
      function show_price_logged($price){
      if(is_user_logged_in() ){
      return $price;
      remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
      remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
      remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 40 );
      remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
      return '<a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">Login to See Prices</a>';
    5. ok i did it, but add to cart is still there =/

    6. Sorry to hear that πŸ™‚ I will need to take a look at your template files in order to help. There must be something wrong with this as maybe that’s the wrong hook: remove_action( ‘woocommerce_single_product_summary‘, ‘woocommerce_template_single_add_to_cart’, 40 )

  82. I wish remove the prices but the functions adding to cart and finalize purchases continued to work, but without showing prices.
    This would serve to generate budgets. And this code doesnt work, the prices continue in the page. I’m paste the code in functions.php file of my template bin. Please, help me

    1. Vinicios, are you asking to remove prices only? Can you send a screenshot?

    2. Yes, i want to remove all prices of site or change the price by a text. Screenshot of my site: http://s14.postimg.org/fjfh7yczl/Untitled_2.jpg

    3. Check this blog out https://businessbloomer.com/woocommerce-add-prefix-suffix-product-prices/ and use the following modified function:

      // Remove price and add text
      add_filter('woocommerce_price_html', 'custom_text');
      add_filter('woocommerce_variable_price_html', 'custom_text');
      function custom_text() {
      $product = new WC_Product( get_the_ID() );
      $price = '<span class="price-text">TEXT HERE</span>';
      return $price;
    4. Look the screenshot: http://s18.postimg.org/5ozodjhux/Untitled_3.jpg

      The code doesn’t work for all products and the text is dont showed correct.

      I’m try to use this too: https://businessbloomer.com/woocommerce-hide-column-cart-table/#comment-990 And when i put in the css file, it is stay with a syntax error.

      Pleas, help me

    5. I improved the code, take a look πŸ™‚

  83. Thanks for this post. The code has unfortunately stopped working! Do you have a replacement code?

    Thank you in advance.

    1. Jessica, thank you for your comment! What error do you get on your website when you activate this code now? Or what did you do right before the code stopped working e.g. updated Woocommerce to what version? Thank you πŸ™‚

    2. Thanks for the quick reply. This hides the prices to those not logged in but the add to cart feature is still not working. I read in another comment below that it is probably a theme issue? I am using the Travelify / Travelify Child theme and cannot seem to find where or what line β€œwoocommerce_template_single_add_to_cart” is located?

    3. Yes, it could be that your theme has changed something in the hook, for example: remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 50 ). please note the “50” at the end, instead of “30”. That priority could have been changed by your theme.

      Can you search for “woocommerce_template_single_add_to_cart” across your parent and child template files? (I use Notepad++ for this reason)

    4. Me again! I download Notepad++ but am not exactly sure how to use it to search for that?

    5. Download and extract your template files in your computer – then open Notepad++ and from the top menu select Search > Find in Files. Browse through your computer to find the template folder and that should do the trick!

    6. Thank you! I was able to search correctly but no results come up in travelify http://colorlib.com/wp/themes/travelify/ Do you have any other suggestions?

    7. Weird πŸ™‚ If you send me your WordPress login/pwd and FTP hostname/username/pwd via email at infoATbusinessbloomer.com I can take a look!

    8. Jessica, I published a new version of the code – this should hide the add to cart button as well!

  84. Dear Rodolfo Melogli,

    i designed a eCommerce website as i share you the URL. But now i stuck with a problem. i.e. as per the company norms and conditions we can’t show the products price to guest user, means only register members can see the products price. to solve the problem i have come across with your solution. but after putting your code in function.php, i can’t find out anything please help me.


    1. Prabir, thanks for your message! It seems you fixed this? If yes, what was the problem? Thanks!

    2. No, I just Paste the code but then what to do.

    3. Once you paste the code in your functions.php it should work automatically, you don’t need to take any additional step πŸ™‚

    4. sory to say its not work. please please help me.

    5. Prabir, it worked for others so that’s weird. If you send me your WordPress login/pwd at infoATbusinessbloomer.com I can take a look!

    6. why its not remove the add to cart button for guest user. please help.

    7. Prabir, I can take a look at your code. Feel free to send me your WordPress login/password

    8. It works now, I just published a new version πŸ™‚

  85. This code is not working for me… Hiding prices but not Add To Cart.

    1. Tayfun, thanks for your comment. It’s probably due to your theme, as they probably moved the “woocommerce_template_single_add_to_cart” already and assigned a different number (30 is the default). I recommend searching within your theme files for “woocommerce_template_single_add_to_cart” and you should be able to identify if they changed the hook. Hope this helps!

    2. Code should now work – check out the new version!

  86. Thank you this was very helpful. Exactly what I was looking for.

    1. Awesome Tim, thanks for your feedback!

  87. Thanks for this code, it is very helpful. However, it did not remove the Add to Cart button for me. Here is the page I am referring to:


    1. I don’t see any add to cart there πŸ™‚

    2. It works now – check the new code πŸ™‚

  88. Hi! I need to know how to get the icon to add to cart when not logged, please consider to make the same money can be added to the cart. I leave the site for your review. thank you very much


    1. Francisco, thanks for your comment. I don’t fully understand what you are trying to do. Are you asking to remove the “add to cart icon”?

  89. Thanks for useful snippets.

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.