The placeholders are left out because the fields are very small by default/in most themes, and this would overcrowd the field. A theme may remove the field headers and this leaves the fields unidentified (note that this is against common practice for WooCommerce). You can fix this by adding them manually.
add_filter( 'woocommerce_billing_fields', 'woocommerce_myparcel_checkout_placeholders', 999, 2);
add_filter( 'woocommerce_shipping_fields', 'woocommerce_myparcel_checkout_placeholders', 999, 2);
function woocommerce_myparcel_checkout_placeholders( $fields, $country = '') {
foreach ($fields as $key => &$field) {
if ($key == 'billing_house_number' || $key == 'shipping_house_number') {
$field['placeholder'] = 'Huisnummer';
}
if ($key == 'billing_house_number_suffix' || $key == 'shipping_house_number_suffix') {
$field['placeholder'] = 'Huisnummer toevoeging (optioneel)';
}
}
return $fields;
}
(read this if you don’t know where to place this code)
Which theme do you use?
Hope that helps!
Ewout
Great! That works like a charm. Thanks for the quick reply!
Hi there!
I had the same problem and the filters fixed it for me as well. One remaining issue is that I’m running multiple languages on my website via Polylang and since this is a hard-coded filter, can I make it so that it will recognize which language is currently loaded? Normally I would change this in .po files via Loco Translate, but I suppose this is currently not possible.
Thanks,
mjrc
Hi! It’s best if you contact Polylang support directly. You can use
__( 'Nr.', 'woocommerce-myparcel' )
and
__( 'Suffix', 'woocommerce-myparcel' )
instead of the strings ‘Huisnummer’ & ‘Huisnummer toevoeging (optioneel)’ too, and then just enter the corresponding translations in Loco translate (add a translation for en_US/en_GB if you want to change the original strings too).
Ewout