I have a problem with woocommerce filter which are written in php.
In this example I like hook into the product tabs and display only a specific tab in a specific category what does its job very well.
add_filter( 'wc_tab_manager_product_tabs', 'wc_tab_manager_product_tabs' );
function wc_tab_manager_product_tabs( $tabs ) {
global $product;
foreach ( $tabs as $tab_name => $tab ) {
if ( 'my-tab' == $tab_name ) {
$categories = wp_get_post_terms( $product->id, 'product_cat', array( 'fields' => 'names' ) );
if ( ! in_array( 'Sample Category', $categories ) ) {
unset( $tabs[ $tab_name ] );
}
}
}
return $tabs;
}
But what if I need to show it on more than Sample Category? how can I add
I tried with 'Sample Category', 'Sample Category', $categories but it does not work...
and what if I need more than this one my-tab?
Can anybody help me to understand?