I am wondering if there is a way to hide the related product tab in the single product page only if the product has no categories set.
This is what I tried:
global $product;
// Return the product categories
$categories = $product->get_categories( ', ', ' ' . _n( ' ', ' ', $cat_count, 'woocommerce' ) . ' ', ' ' );
if(empty($categories)){
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
}
This was added to functions.php but it is not working. Anyone would have a better idea?