Hide Add-to-cart button on category pages
-
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)The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Hide Add-to-cart button on category pages’ is closed to new replies.