Here’s how you can remove the “Add to cart” button from specific products in your WooCommerce store (per ID)
Remember to replace
id1, id2, id3
with the IDs of the product’s you’d like to remove the button from. If you need help finding the product IDs, please see https://bobwp.com/find-product-id-woocommerce/
Archive/shop page:
add_filter( 'woocommerce_loop_add_to_cart_link', 'remove_add_to_cart_buttons_archive', 1 ); function remove_add_to_cart_buttons_archive( $button ) { global $product; $products_with_no_buttons = array( id1, id2, id3 ); if ( in_array( $product->get_id(), $products_with_no_buttons ) ) { return ''; } return $button; }
Single product pages
add_action( 'woocommerce_single_product_summary', 'remove_add_to_cart_button_single_products', 1 ); function remove_add_to_cart_button_single_products() { global $product; $products_with_no_buttons = array( id1, id2, id3 ); if ( is_single() && in_array( $product->get_id(), $products_with_no_buttons ) ) { remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); } }
You can add this code to your site following the instructions here:
How to add custom code to your WooCommerce/WordPress site the right way
Have any feedback? Be sure to let me know here: Contact me