skip to Main Content

I’m trying to remove add to cart button from WooCommerce everywhere and leave it only in single product page

I have made a lot of research and I tried this code but it doesn’t work

remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );

i want users can only add a product to cart in each single product page

2

Answers


  1. if your code doesn’t work with the hook then you can do hide by css as well

    Login or Signup to reply.
  2. Add the follows code snippet in your active theme’s functions.php to do that –

    add_filter( 'woocommerce_loop_add_to_cart_link', 'remove_add_to_cart_from_all_listing', 99, 3 );
    function remove_add_to_cart_from_all_listing( $add_to_cart, $product, $args ){
        if( is_product() ) return $add_to_cart;
        return false;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search