I am using the code coming from this answer:
Hiding tabs only for some products in WooCommerce single product pages
Here is that code:
add_filter( 'woocommerce_product_tabs', 'conditionaly_removing_product_tabs', 98 );
function conditionaly_removing_product_tabs( $tabs ) {
// Get the global product object
global $product;
// Get the current product ID
$product_id = method_exists( $product, 'get_id' ) ? $product->get_id() : $product->id;
// Define HERE your targetted products IDs in this array <=== <=== <===
$target_products_ids = array(123,152,162);
// If the current product have the same ID than one of the defined IDs in your array,…
// we remove the tab.
if(in_array($product_id, $target_products_ids)){
// KEEP BELOW ONLY THE TABS YOU NEED TO REMOVE <=== <=== <=== <===
unset( $tabs['description'] ); // (Description tab)
unset( $tabs['reviews'] ); // (Reviews tab)
unset( $tabs['additional_information'] ); // (Additional information tab)
}
return $tabs;
}
This code works fine to unset or hide tabs from specific products.
Instead I would like to unset or hide tabs from specific product categories.
How can I do it for product categories?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…