{"id":51387,"date":"2015-08-06T03:10:47","date_gmt":"2015-08-06T07:10:47","guid":{"rendered":"http:\/\/www.templatemonster.com\/help\/?p=51387"},"modified":"2016-02-25T03:51:54","modified_gmt":"2016-02-25T08:51:54","slug":"woocommerce-how-to-hide-prices-and-add-to-cart-for-unregistered-users","status":"publish","type":"post","link":"https:\/\/www.templatemonster.com\/help\/woocommerce-how-to-hide-prices-and-add-to-cart-for-unregistered-users.html","title":{"rendered":"WooCommerce. How to hide prices and Add to Cart for unregistered users"},"content":{"rendered":"<p><a href=\"http:\/\/www.youtube.com\/watch?v=lfbJxQ6KkrU?width=1280&amp;height=720\" rel=\"prettyPhoto\">WooCommerce. How to hide prices and Add to Cart for unregistered users<\/a><\/p>\r\n<p>This tutorial shows how to hide <strong>Prices and Add to Cart<\/strong> for unregistered users in WooCommerce.<\/p>\r\n<p><a href=\"\/help\/wp-content\/uploads\/2015\/08\/WooCommerce.-How-to-hide-prices-and-Add-to-Cart-for-unregistered-users-1.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2015\/08\/WooCommerce.-How-to-hide-prices-and-Add-to-Cart-for-unregistered-users-1-300x210.jpg\" alt=\"WooCommerce. How to hide prices and Add to Cart for unregistered users-1\" width=\"300\" height=\"210\" class=\"aligncenter size-medium wp-image-51388\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/WooCommerce.-How-to-hide-prices-and-Add-to-Cart-for-unregistered-users-1-300x210.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/WooCommerce.-How-to-hide-prices-and-Add-to-Cart-for-unregistered-users-1-150x105.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/WooCommerce.-How-to-hide-prices-and-Add-to-Cart-for-unregistered-users-1.jpg 1000w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\r\n<ol>\r\n<li>\r\n<p>In order hide <strong>Prices and Add to Cart<\/strong> for unregistered users, log into <strong>WordPress Dashboard<\/strong> and navigate to the <strong>Appearance -> Editor<\/strong> tab. Open the <strong>custom-functions.php<\/strong> file.\r\n  <\/p>\r\n<\/li>\r\n<li>\r\n<p>Please note if you&#8217;re editing file via <a target=\"_blank\" href=\"\/help\/how-upload-files-server-2.html\">FTP<\/a> or <a target=\"_blank\" href=\"\/help\/how-to-upload-files-to-a-server-using-cpanel-webhost-manager-whm.html\">cPanel file manager<\/a>, you can find the file required in the <strong>wp-content\/themes\/themeXXXXX\/includes<\/strong> folder on server.<\/p>\r\n<\/li>\r\n<li>\r\n<p>Please make sure to back up the file, i.e. save copy of the original file before editing it.<\/p>\r\n<\/li>\r\n<li>\r\n<p>Scroll down the file and paste the following code before the closing <strong>?><\/strong> tag:<\/p>\r\n<pre class=\"brush:php\">\/\/ Hide prices\r\n    add_action('after_setup_theme','activate_filter') ;\t\r\n    function activate_filter(){\r\n    add_filter('woocommerce_get_price_html', 'show_price_logged');\r\n    }\r\n    function show_price_logged($price){\r\n    if(is_user_logged_in() ){\r\n    return $price;\r\n    }\r\n    else\r\n    {\r\n    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );\r\n    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );\r\n    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );\r\n    remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );\r\n    return '&lt;a href=&quot;' . get_permalink(woocommerce_get_page_id('myaccount')) . '&quot;&gt;Login to See Prices&lt;\/a&gt;';\r\n    }\r\n    }<\/pre>\r\n<\/li>\r\n<li>\r\n<p>Update the file and log out from admin panel to check the changes on the front-end:<\/p>\r\n<p><a href=\"\/help\/wp-content\/uploads\/2015\/08\/WooCommerce.-How-to-hide-prices-and-Add-to-Cart-for-unregistered-users-2.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2015\/08\/WooCommerce.-How-to-hide-prices-and-Add-to-Cart-for-unregistered-users-2-300x210.jpg\" alt=\"WooCommerce. How to hide prices and Add to Cart for unregistered users-2\" width=\"300\" height=\"210\" class=\"aligncenter size-medium wp-image-51389\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/WooCommerce.-How-to-hide-prices-and-Add-to-Cart-for-unregistered-users-2-300x210.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/WooCommerce.-How-to-hide-prices-and-Add-to-Cart-for-unregistered-users-2-150x105.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/WooCommerce.-How-to-hide-prices-and-Add-to-Cart-for-unregistered-users-2.jpg 1000w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>\r\n  <\/li>\r\n<\/ol>\r\n<p>Feel free to check the detailed video tutorial below:<\/p>\r\n<p><a href=\"http:\/\/www.youtube.com\/watch?v=lfbJxQ6KkrU?width=1280&amp;height=720\" rel=\"prettyPhoto\">WooCommerce. How to hide prices and Add to Cart for unregistered users<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to hide <strong>Prices and Add to Cart<\/strong> for unregistered users in WooCommerce.<\/p>\n","protected":false},"author":65,"featured_media":51391,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1556],"tags":[1301,544,2022,2418],"_links":{"self":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/51387"}],"collection":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/comments?post=51387"}],"version-history":[{"count":0,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/51387\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media\/51391"}],"wp:attachment":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media?parent=51387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/categories?post=51387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/tags?post=51387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}