Last updated
The Refer a Friend tab appears on every product page. To hide it everywhere, turn on Display Settings → Hide on Product Tabs. To hide it for some categories only, or to show it only on some, use one of these snippets.
Before you start: read Add code snippets safely. Checked with version 4.4.12. Use category slugs, which you’ll find in Products → Categories.
Hide the tab in some categories
add_filter( 'wpgens_raf_tab_disable', function ( $hide ) {
$categories = array( 'gift-cards', 'sale' );
if ( is_product() && has_term( $categories, 'product_cat', get_the_ID() ) ) {
return true;
}
return $hide;
} );
Show the tab only in some categories
add_filter( 'wpgens_raf_tab_disable', function ( $hide ) {
$categories = array( 'clothing' );
if ( is_product() && ! has_term( $categories, 'product_cat', get_the_ID() ) ) {
return true;
}
return $hide;
} );
These snippets only change where the tab is shown. Referral links still work for every product. To reward only referrals that include certain products, see Only reward referrals that include specific products.
Check it worked
Open a product in one of your categories, and one outside them. The Refer a Friend tab should only appear where you want it.