I want to hide the button on my shop pages, but I would like to show it on other posts and pages.
I\'ve found this code to hide the add to cart button on my whole we
add_action('wp','only_add_bierkoerier_in_cart', 'woocommerce_before_cart');
function only_add_bierkoerier_in_cart() {
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$bierkoerier_in_cart = false;
$categories = get_categories();
if ( has_term( 'bierkoerier', 'product_cat', $cart_item['product_id'] ) ) {
$bierkoerier_in_cart = true;
break;
}
}
if($bierkoerier_in_cart) {
wc_print_notice( 'omdat u bierkoerier producten in uw winkelwagen heeft
kunt u geen winkelitems toevoegen', 'notice' );
if(is_shop() || is_product() || is_product_category()) {
remove_action( 'woocommerce_after_shop_loop_item','woocommerce_template_loop_add_to_cart' );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
}
}
}