Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Hide Add-to-cart button on category pages

$
0
0

Replies: 0

Hi

In WooCommerce I would like to hide quantity and Add-to-cart button on all list pages (like category) – but NOT on product page.

If I use:


add_filter( 'woocommerce_is_purchasable', '__return_false');

in my functions.php, it hides it on all pages. But I want to show it on product pages, so I tried something more specific and used this to only target category pages:


function remove_add_to_cart(){
	 if ( is_product_category() ) {
	 	add_filter( 'woocommerce_is_purchasable', '__return_false');
}
} 
add_action('woocommerce_single_variation','remove_add_to_cart');

That doesn’t do anything.

I also tried this:


function remove_add_to_cart(){
	 
	 if ( is_product_category() ) {
	 	add_filter( 'woocommerce_is_purchasable', '__return_false');
		 // Remove cart from variable products
        remove_action( 'woocommerce_single_variation','woocommerce_single_variation_add_to_cart_button', 20 );
}
} 
add_action('woocommerce_single_variation','remove_add_to_cart');

That works for all variable products, but not for simple products.

What am I doing wrong…?
I hope you can help. :o)


Viewing all articles
Browse latest Browse all 59525

Trending Articles