Solution:
In the following functions, you will have to define one or many product IDs inside the code.
This first hooked function will remove the product from product catalog:
add_filter( 'woocommerce_product_is_visible', 'filter_product_is_visible', 20, 2 );
function filter_product_is_visible( $is_visible, $product_id ){
// HERE define your products IDs (or variation IDs) to be set as not visible in the array
$targeted_ids = array(37, 43, 51);
if( in_array( $product_id, $targeted_ids ) )
$is_visible = false;
return $is_visible;
}
To remove the link from cart items in cart page, you can use the following
add_filter( 'woocommerce_cart_item_name', 'filter_cart_item_name', 20, 3 );
function filter_cart_item_name( $product_name, $cart_item, $cart_item_key ) {
// HERE define your products IDs (or variation IDs) to be set as not visible in the array
$targeted_ids = array(37, 43, 51);
if( in_array( $cart_item['data']->get_id(), $targeted_ids ) && is_cart() )
return $cart_item['data']->get_name();
return $product_name;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Is also possible to redirect the target products pages to the main shop.