I have been trying to hide all products from a specific category (from shop page and single page) using this StackOverFlow answer code and following instructions on this other forum thread
On "Exclude specific product categories on Woocommerce single product pages" answer code I have defined one of my product categories as follow (here the term Id 43):
$category_ids = array( 43 );
I just need that all products of this category (ID 43) to be added to the cart and buy.
One of the products of the category ID 43 "Plan": https://mamasmateas.atac.cl/product/plan-personalizado-sin-seguimiento/
The other code I have tested is:
add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 );
function ts_get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
// if it is a product category and on the shop page
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_shop() ) {
foreach ( $terms as $key => $term ) {
if ( ! in_array( $term->slug, array( 'plan' ) ) ) { //pass the slug name here
$new_terms[] = $term;
}
}
$terms = $new_terms;
}
return $terms;
}
Any help would be much appreciated.