Remove Add to Cart Buttons on WooCommerce Shop Archives Page

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); 

See more:

We've 7 Responses

  1. 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="&#039; .get_permalink(woocommerce_get_page_id(&#039;myaccount&#039;)). &#039;" rel="nofollow">Login</a> or <a href="&#039;.site_url(&#039;/wp-login.php?action=register&amp;redirect_to=&#039; . get_permalink()).&#039;" rel="nofollow">Register</a> to see price!';
    
    }
    Mike
    • June 21st, 2013 at 7:38 am

      For add a link button product add this :

      <a>id ) .'"&gt;Lire plus</a>

      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 ) .'"&gt;Lire plus</a>';
      
      }
      
      Mike
  2. 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!!!!

    /**
     * remove add to cart buttons on shop archive page
     */
     
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
    
    Lola Teigland
  3. 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/

    Alexander
  4. 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

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]