I've been trying to apply a gettext
filter to return two different results for different product categories (or read as categories for posts, non-woocommerce specific).
I cant seem to get it right. This loads, but does not actually apply the conditional, it always defaults to else condition. What am I missing? This is added to my child theme's functions.php.
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related Products' :
if (is_product_category( 'providers' ) ) {
$translated_text = __( 'Check out these other Providers', 'woocommerce' );
} else {
$translated_text = __( 'Check out reviews of other Providers', 'woocommerce' );
}
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );