Hide add to cart button via hook

Posted in: Newspaper
Post count: 11

I need to hide the add to cart button from the product page. I’m using the “woo add to cart” widget.
the classic hook is not working:
add_action( 'any-hook-same-result', 'remove_add_to_cart_buttons', 1 );

function remove_add_to_cart_buttons() {
if( is_shop()) {
remove_action( 'any-hook-same-result', 'woocommerce_template_loop_add_to_cart' );
}
}

what can i do?

Post count: 27744

Hi,

Can you please provide more details about what you want to hide with screenshots?

Thank you!

Post count: 11

image link

I need a hook, or a function, to manage the rendering of this button.
Thanks.

Post count: 27744

Hi,

You can hide it using custom code css -> https://i.imgur.com/I6FKrn3.png form.cart button.single_add_to_cart_button
{
display: none;
}

Set the code in theme panel -> custom code -> custom css.

Thank you!

Post count: 11

Ok, thanks for the anwser.
Seriously, i really need to know if there’s is a way to manage the render of the button via hooks. Like this:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
Why the standard hooks are not working?
Thanks

Post count: 35449

Hi monema, the hooks that you are try to use are not working because on your product page you are using cloud templates that can be edited using the tagDiv Composer and those a different from standard woo shortcodes. What you can do is to remove the add to cart button by editing the template with tagDiv Composer – https://i.imgur.com/q333Xxt.pnghttps://i.imgur.com/YHlLR2F.png
Thank you for your understanding!

Post count: 11

Is possible, via code, to override the element “woo-add-to-cart” in my child theme?
Thanks

Post count: 35449

Hi,
Unfortunately that element can’t be override, sorry!
Only the elements from tagDiv Standard Pack can be overwritten in child theme – https://forum.tagdiv.com/the-child-theme-support-tutorial/
Thank you for your understating!

Viewing 8 posts - 1 through 8 (of 8 total)
The forum ‘Newspaper’ is closed to new topics and replies.