Hi, it’s me, again,
I managed to make it work, after 10 minutes. I was sure I couldn’t do it yesterday, but ah, fresh mind..
You can hide a product, or multiple, using ID’s. Check out the following snippet:
function custom_pre_get_posts_query( $q ) {
// Read cart contents
// Get ids of products which you want to hide
$array_of_product_id = array(3139);
$q->set( 'post__not_in', $array_of_product_id );
}
add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );