Remove both “Add to cart” and “Read more” Buttons

Different ways how you can completely hide Add to cart buttons on specific pages of your store without any CSS or plugins.

But before we dive into the code, let me explain the difference between hiding the “Add to cart” button and making products non-purchasable.

In this tutorial we are about just to hide the buttons, that’s all, so products still will be available for purchase, e.g. in the cart or maybe via a direct link. If you want to completely disable product purchases, this tutorial is for you.

You can also do both. Because non-purchasable products still have “Read more” buttons instead of “Add to cart”.

On Archive Pages, Related Products, Cross-sells, Upsells

Archive pages are:

This code below also removes “Add to cart” buttons from upsells, cross-sells and related products sections.

remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');

You can add this code to your theme functions.php file and here is the result.

Remove add to cart button from product archive pages
Please note, that Read more button disappears too.

You can also read my other articles on how to remove product prices and the Sale! badge.

But what if you do not need to remove the add to cart button from all the archive pages? Let’s say you need to remove it from certain categories or from related products section.

Conditional tags is the answer.

/*
 * Remove "Add to Cart" button from the product category "Uncategorized"
 */
add_action('wp', 'misha_remove_add_to_cart_product_categories' );
 
function misha_remove_add_to_cart_product_categories(){
	if( is_product_category( 'uncategorized' ) ) {
		remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
	}
}

In the WooCommerce product loop it is also possible to use filter hook woocommerce_loop_add_to_cart_link to remove “Add to cart” from products with certain IDs or even for certain product types.

/**
 * Hide the button for the product with ID = 10 AND for variable products
 */
add_filter('woocommerce_loop_add_to_cart_link', function( $add_to_cart_html, $product ) {
 
	if( $product->get_id() == 10 || $product->is_type( 'variable' ) ) {
		return '';
	}
	return $add_to_cart_html;
 
}, 10, 2 );

On Single Product Pages

Easy-breezy 😁

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');
Remove add to cart button from single product pages

More about turning WooCommerce Store into a Catalog

Misha Rudrastyh

Misha Rudrastyh

I love WordPress, WooCommerce and Gutenberg so much. 10 yrs of experience.

Need some custom developer help? Let me know

Follow Misha

Need some help with WooCommerce?

If you need some professional developer help, I will be happy to assist you.

Contact me Who I am?

Leave a comment

php js HTML CSS Code