How to hide/show RAF product tab for specific product category?

If you want to hide Refer a Friend product tab from a specific category of products, use the code below, just change "clothing" to your category slug. That way, 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 single one, just put "!" before in_array (without quotes) and change clothing to the category you want product tab to be displayed.

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'));
		}
	}
}

Still need help? Contact Us Contact Us