{"id":256,"date":"2020-08-10T16:13:00","date_gmt":"2020-08-10T16:13:00","guid":{"rendered":"https:\/\/demo.wpartisan.net\/developmentsite\/how-can-i-remove-hide-add-to-cart-button-from-shopcategory-and-product-details-page\/"},"modified":"2024-12-05T13:55:39","modified_gmt":"2024-12-05T13:55:39","slug":"how-can-i-remove-hide-add-to-cart-button-from-shopcategory-and-product-details-page","status":"publish","type":"post","link":"https:\/\/demo.wpartisan.net\/developmentsite\/how-can-i-remove-hide-add-to-cart-button-from-shopcategory-and-product-details-page\/","title":{"rendered":"How can i remove\/hide Add to Cart button from shop,category and product details page?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>We can use \u2018woocommerce_before_shop_loop_item\u2019 action hook to remove\/hide add to cart button from all the products, which is not good in all cases<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code \\&quot;wp-block-code\\&quot;\"><code lang=\"\\&quot;php\\&quot;\" class=\"language-\\&quot;php\\&quot;\">add_action( 'woocommerce_before_shop_loop_item', 'ratcw_remove_archive_add_to_cart_button' );\nfunction ratcw_remove_archive_add_to_cart_button(){\n\tremove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The above function will remove\/hide Add to Cart for all the products. So I think it will not be good.<\/strong> Almost every store owner wants to remove\/hide Add to Cart for a specific product. To achieve this goal, you need to add a custom meta field with the products. You can accomplish this using a plugin( ACF or other plugins ) or custom code. I can show you here using the custom code:<\/p>\n\n\n\n<pre class=\"wp-block-code \\&quot;wp-block-code\\&quot;\"><code lang=\"\\&quot;php\\&quot;\" class=\"language-\\&quot;php\\&quot;\">add_action( 'woocommerce_product_options_general_product_data', 'ratcw_woocommerce_product_custom_fields' ); \nfunction ratcw_woocommerce_product_custom_fields () {\n\tglobal $woocommerce, $post;\n\techo '&lt;div class=\" product_custom_field \">';\n\t\twoocommerce_wp_checkbox( array(\n\t\t\t'id'      => 'ratcw_hide_add_to_cart',\n\t\t\t'value'   => esc_attr( get_post_meta( get_the_ID(), 'ratcw_hide_add_to_cart', true ) ),\n\t\t\t'label'   => esc_html__( 'Hide\/Remove add to cart :', 'text-domain' ),\n\t\t\t'desc_tip' => true,\n\t\t\t'description' => esc_attr__( 'Hide\/Remove add to cart in frontend', 'text-domain' ),\n\t\t) );\n\techo '&lt;\/div>';\n}<\/code><\/pre>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/wpartisan.net\/wp-content\/uploads\/2020\/08\/iimg.png\" alt=\"Save product meta\">\n\n\n\nThe add\/edit product screen interface will look like the below screenshot.\n<img decoding=\"async\" src=\"https:\/\/wpartisan.net\/wp-content\/uploads\/2020\/08\/paes.png\" alt=\"Hide Add to Cart\">\n\n\n\n<p class=\"wp-block-paragraph\">So to remove\/Hide Add to Cart from the shop, category and tags pages, you need to add the code like below:<\/p>\n\n\n\n<pre class=\"wp-block-code \\&quot;wp-block-code\\&quot;\"><code lang=\"\\&quot;php\\&quot;\" class=\"language-\\&quot;php\\&quot;\">add_action( 'woocommerce_before_shop_loop_item', 'ratcw_remove_archive_add_to_cart_button' );\nfunction ratcw_remove_archive_add_to_cart_button(){\n\tglobal  $product ;\n    $product_id = $product->get_id();\n\t$ratcw_hide_add_to_cart = get_post_meta( $product_id, 'ratcw_hide_add_to_cart', true );\n\tif ( isset( $ratcw_hide_add_to_cart ) &amp;&amp; $ratcw_hide_add_to_cart === 'yes' ) {\n\t\tremove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );\n\t}else{\n\t\tadd_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );\n\t}\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>To remove\/hide Add to Cart button from the product details page, you need to add the below code:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code \\&quot;wp-block-code\\&quot;\"><code lang=\"\\&quot;php\\&quot;\" class=\"language-\\&quot;php\\&quot;\">add_action( 'woocommerce_single_product_summary', 'ratcw_remove_add_to_cart_button_from_single_product' );\nfunction ratcw_remove_add_to_cart_button_from_single_product(){\n\tglobal  $product ;\n    $product_id = $product->get_id();\n\t$ratcw_hide_add_to_cart = get_post_meta( $product_id, 'ratcw_hide_add_to_cart', true );\n\tif ( isset( $ratcw_hide_add_to_cart ) &amp;&amp; $ratcw_hide_add_to_cart === 'yes' ) {\n\t\tremove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );\n\t}\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">R<strong>emove\/Hide Add to Cart button using Plugin:<\/strong><\/p>\n\n\n\nIf you want to hide\/remove the product Add to Cart button from the product list page or product details page using any WordPress plugin, please first think about the plugin name <a href=\"https:\/\/wordpress.org\/plugins\/remove-add-to-cart-button-for-woocommerce\/\" target=\"_blank\" rel=\"noopener noreferrer\">Remove Add to Cart Button for WooCommerce<\/a>.\n<h3>Free features<\/h3>\n<ul>\n<li>Remove Add to Cart button for all<\/li>\n<li>Remove Add to Cart button only for the visitors<\/li>\n<li>Show login button when Add to Cart button is removed for the visitors<\/li>\n<li>Set login URL ( if you not set any URL here then it will take you to default login\/register page URL ) from plugin settings tab<\/li>\n<li>Change login button label from settings tab<\/li>\n<li>Have option to set message when Add to Cart is hidden<\/li>\n<li>Hide product price<\/li>\n<li>Easy to use<\/li>\n<li>Translation ready<\/li>\n<\/ul>\n<h3>Premium features<\/h3>\n<ul>\n<li>All Free Features<\/li>\n<li>Remove Add to Cart Button Based on User Rules<\/li>\n<li>Remove Add to Cart Button Based on Countries<\/li>\n<li>Set Category Wise Remove Add to Cart Button Conditions( means you can apply remove Add to Cart conditions for the all products in a category )<\/li>\n<li>Priority Email Support<\/li>\n<\/ul>\n\n\n<div id='gallery-1' class='gallery galleryid-256 gallery-columns-3 gallery-size-thumbnail'><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/demo.wpartisan.net\/developmentsite\/how-can-i-remove-hide-add-to-cart-button-from-shopcategory-and-product-details-page\/cratc\/'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/demo.wpartisan.net\/developmentsite\/wp-content\/uploads\/2020\/08\/cratc-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/demo.wpartisan.net\/developmentsite\/how-can-i-remove-hide-add-to-cart-button-from-shopcategory-and-product-details-page\/rcp\/'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/demo.wpartisan.net\/developmentsite\/wp-content\/uploads\/2020\/08\/rcp-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/demo.wpartisan.net\/developmentsite\/how-can-i-remove-hide-add-to-cart-button-from-shopcategory-and-product-details-page\/screenshot-1-2-2\/'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/demo.wpartisan.net\/developmentsite\/wp-content\/uploads\/2020\/08\/screenshot-1-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/demo.wpartisan.net\/developmentsite\/how-can-i-remove-hide-add-to-cart-button-from-shopcategory-and-product-details-page\/screenshot-2-2-2\/'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/demo.wpartisan.net\/developmentsite\/wp-content\/uploads\/2020\/08\/screenshot-2-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/demo.wpartisan.net\/developmentsite\/how-can-i-remove-hide-add-to-cart-button-from-shopcategory-and-product-details-page\/screenshot-3-2-2\/'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/demo.wpartisan.net\/developmentsite\/wp-content\/uploads\/2020\/08\/screenshot-3-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/demo.wpartisan.net\/developmentsite\/how-can-i-remove-hide-add-to-cart-button-from-shopcategory-and-product-details-page\/screenshot-4-5\/'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/demo.wpartisan.net\/developmentsite\/wp-content\/uploads\/2020\/08\/screenshot-4-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/demo.wpartisan.net\/developmentsite\/how-can-i-remove-hide-add-to-cart-button-from-shopcategory-and-product-details-page\/screenshot-5-5\/'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/demo.wpartisan.net\/developmentsite\/wp-content\/uploads\/2020\/08\/screenshot-5-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/div><\/figure>\n\t\t<\/div>\n\n\n\n<p class=\"align-center\">Download Remove Add to Cart Button for WooCommerce Plugin from the WordPress directory.<\/p>\n\t<a class=\"btn button\" href=\"https:\/\/wordpress.org\/plugins\/remove-add-to-cart-button-for-woocommerce\/\">Click Here<\/a>\n","protected":false},"excerpt":{"rendered":"<p>To remove\/hide Add to Cart button from the WooCommerce shop, category, tag and product details page, you need to use some WooCommerce action hook. Please read more to get the action functions that I have used to remove Add to Cart button, product price etc.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[15,16,25,18],"tags":[22,23,24],"class_list":["post-256","post","type-post","status-publish","format-standard","hentry","category-php","category-plugin","category-woocommerce","category-wordpress","tag-hide-add-to-cart","tag-hide-cart-button","tag-remove-add-to-cart-woocommerce"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"WPArtisan","author_link":"https:\/\/demo.wpartisan.net\/developmentsite\/author\/developmentsiteauth\/"},"uagb_comment_info":4,"uagb_excerpt":"To remove\/hide Add to Cart button from the WooCommerce shop, category, tag and product details page, you need to use some WooCommerce action hook. Please read more to get the action functions that I have used to remove Add to Cart button, product price etc.","_links":{"self":[{"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/posts\/256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/comments?post=256"}],"version-history":[{"count":1,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/posts\/256\/revisions"}],"predecessor-version":[{"id":2307,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/posts\/256\/revisions\/2307"}],"wp:attachment":[{"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/media?parent=256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/categories?post=256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/tags?post=256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}