Customizing Checkout Fields and issue translation

Solution:

Adding a custom function hooked in woocommerce_default_address_fields filter hook, you can change the ‘address_2’ placeholder field in to something localisable, this way:

add_filter( 'woocommerce_default_address_fields' , 'overriding_postcode_placeholder_address_fields' );

function overriding_postcode_placeholder_address_fields( $address_fields ) {

     // Set HERE your theme domain (the theme slug used for translations)
     $domain = 'your_theme_domain';

     // For 'address_2' fields
     $address_fields['address_2']['placeholder'] = __('Apartment, suite, unit etc.', $domain);

     // For 'postcode' fields
     $address_fields['postcode']['placeholder'] = __('your placeholder text here', $domain);

     return $address_fields;
} 

I have Add to ‘postcode’ field, a place holder. So now you have to set your theme domain in this function and also the place holder text for ‘postcode’ field. depending on what tool or plugin you ara using for translations, this translations will be available within your theme domain.

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

The code is tested and working


Reference: Customizing checkout fields using actions and filters

Advices:

  • On multi-site WordPress installation, WooCommerce is not recommended, as it’s a very sensible plugin that needs more heavy separate server ressources. Also all update process is much more sensible and so on…
  • For WooCommerce multilingual, please have a look to this: Comparing WPML to Free and Paid Alternatives