I'm no PHP expert but I'm good enough to scrape some things together here and there. This is my attempt at hiding the WooCommerce add to cart button from specific category pages:
// Remove the add to cart button from certain power line markers
add_action( 'woocommerce_single_product_summary', 'remove_add_cart_button' );
/**
* Remove add to cart button
*/
function remove_add_cart_button() {
// Categories
$categories = array( 'Power Line Markers' );
if ( has_term( $categories, 'product_cat', get_the_id() ) ) {
remove_action( 'woocommerce_single_variation','woocommerce_single_variation_add_to_cart_button', 20 );
}
}
This works perfectly but it will only remove the add to cart button from specific categories and I'd like to remove it from specific products instead. I'm struggling with the PHP code to do that so I'm hoping someone can put me on the right path.
Thanks in advance and God bless!