This code snippet is over a year old, from before WooCommerce 2.0. I don’t know if this function works with WooCommerce 2.0+.
Remove the ‘add to cart’ buttons on the WooCommerce shop archives page.
/** * remove add to cart buttons on shop archive page */ remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
Waqas
January 19th, 2018 at 7:00 am
You can use also use this plugin: https://wordpress.org/plugins/remove-add-to-cart-woocommerce/ to remove add to cart.
It removes add to cart from
– Complete shop
– individual products
– Specific category
– also hide prices
thanks
Alexander
November 25th, 2017 at 12:28 am
You have to add this code to make products not available for sale in functions.php file .
add_filter('woocommerce_is_purchasable', 'wpblog_specific_product'); function wpblog_specific_product($purchaseable_product_wpblog, $product) { return ($product->id == specific_product_id (512) ? false : $purchaseable_product_wpblog); }For removing add to cart from product pages you simply put this code in woocommerce.php (located wp-content/plugins/woocommerce).
function WpBlog() { 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'); return WooCommerce::instance(); }Reference: https://www.wpblog.com/add-to-cart-button-in-woocommerce-store/
Alexander
November 2nd, 2017 at 6:13 am
For any shop page or product you can disable the the add 2 cart button. You just have to follow these simple steps. In woocommerce.php
function WpBlog() { 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'); return WooCommerce::instance(); }Add this code to the functions.php to disable add to cart from any specific product page
add_filter('woocommerce_is_purchasable', 'wpblog_specific_product'); function wpblog_specific_product($purchaseable_product_wpblog, $product) { return ($product->id == specific_product_id (512) ? false : $purchaseable_product_wpblog); }You can see this article as reference https://www.wpblog.com/add-to-cart-button-in-woocommerce-store/
xaraar
August 9th, 2017 at 3:14 am
Here is a plugin you can use to remove / hide /disable Add to cart
https://wordpress.org/plugins/woo-options/
Lola Teigland
June 25th, 2013 at 12:55 pm
Hi Isabel,
I want to remove the “add to cart” button from the home page because is doesn’t work — it can’t work, because you need to choose variations before you can add to the cart. Instead it redirects to the home page, and that gives me 30-somE pages of duplicate content. Will the code listed at the top of this post work for this? And where do I put it in thefunctions.php file? Mt theme is by Organic themes. THANK YOU!!!!
Mike
June 21st, 2013 at 5:39 am
Hi Isabel,
Your code is good, but my client want show add to cart and if the user arre logged. i have try this code and is good for me !
This solution go to complementary your code.
function remove_loop_button(){ if(is_user_logged_in()){}else 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 ); } add_action('init','remove_loop_button'); add_filter('woocommerce_get_price_html','members_only_price'); function members_only_price($price){ if(is_user_logged_in() ){ return $price; } else return '<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '" rel="nofollow">Login</a> or <a href="'.site_url('/wp-login.php?action=register&redirect_to=' . get_permalink()).'" rel="nofollow">Register</a> to see price!'; }Mike
June 21st, 2013 at 7:38 am
For add a link button product add this :
before “‘;” in the last line
EX :
function remove_loop_button(){ if(is_user_logged_in()){}else 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 ); } add_action('init','remove_loop_button'); add_filter('woocommerce_get_price_html','members_only_price'); function members_only_price($price){ if(is_user_logged_in() ){ return $price; } else return '<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '" rel="nofollow">Pour afficher le prix et acheter connectez-vous!</a><a>id ) .'">Lire plus</a>'; }