I am trying to change some titles on the WooCommerce checkout page.
One of the titles is "Billing details"
I've tried:
function wc_billing_field_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Billing details' :
$translated_text = __( 'Billing Info', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'wc_billing_field_strings', 20, 3 );
I just can't change the text of those, whatever I add to my functions.php or WooCommerce alterations file.
Can you please let me know, how I can change those title?
Note: I would like to make use of action hooks. I don't won't to copy the WooCommerce template file as other options suggests.
Change switch ( $translated_text ) {
with switch ( $text ) {
in your code.
This is because $text
contains the original (undertranslated) text while $translated_text
contains... the name of the variable already indicates it.
Or use
function filter_gettext( $translated, $original_text, $domain ) {
// Is admin
if ( is_admin() ) return $translated;
// No match
if ( $original_text != 'Billing details' ) return $translated;
// Match
$translated = __( 'Billing Info', $domain );
return $translated;
}
add_filter( 'gettext', 'filter_gettext', 10, 3 );