If you want to hide the Refer a Friend product tab from a specific category of products, you can use the code below – just change “clothing” to your category slug. That way, the Refer a Friend product tab won’t be shown for that category of products.
But if you want to hide it from every category except a particular one, just put “!” before in_array (without quotes) and change ‘clothing’ to the category you want the product tab to display.
add_action('wp','wpgens_exclude_product_tab');
function wpgens_exclude_product_tab(){
if(is_product()) {
global $post;
$terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) $categories[] = $term->slug;
if ( in_array( 'clothing', $categories ) ) {
remove_filter('woocommerce_product_tabs',array( WPGens_RAF::instance()->product_tab, 'raf_product_tab'));
}
}
}