I'm simply trying to change the string "SKU" to show something else inside the single-product meta.php file. I'm using a child theme. The parent theme got a woocommerce.php file in the path /inc/compat/. Because of this, as far as I understood, I can't override by simply change the meta.php inside the theme.
So, I've tried to add this function inside woocommerce.php of the parent theme:
function translate_woocommerce($translation, $text, $domain) {
if ($domain == 'woocommerce') {
switch ($text) {
case 'SKU':
$translation = 'TEST';
break;
case 'SKU:':
$translation = 'TEST';
break;
}
}
return $translation; }
add_filter('gettext', 'translate_woocommerce', 10, 3);
But it's not working. Could you please help me?
Thank you very much.
Just a little update: if I put the above code in functions.php of the parent or child theme, I can see that SKU string is changed inside Wordpress dashboard (please check the following image):