Avishay28
Avishay28

Reputation: 2456

Can't change "Postcode / ZIP" field label in woocommerce

I have a site in hebrew based on woocommerce. The translation working great, however, the field "Postcode / ZIP" is refuse to be trasnlate:

enter image description here

I've tried to change it using this code:

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {

    $fields['billing']['billing_postcode']['label'] = 'test';

    return $fields;
}

But something weird happen: when I reload the page I can see the change take effect, but after a second it change back to "Postcode / ZIP". Another weird thing: the above script work for the other fields, something is wrong with that specific field.

Anyone know what's going on?

Thanks!

Upvotes: 0

Views: 3960

Answers (1)

Avishay28
Avishay28

Reputation: 2456

function my_text_strings( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Postcode / ZIP' :
            $translated_text = __( 'test', 'woocommerce' );
            break;
    }
    return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );

Upvotes: 6

Related Questions