Change Checkout Field Labels and Placeholders
Renames checkout fields and their placeholder hints, for example "Town / City" to "City" or "Apartment, suite, unit" to "Flat or floor", without a translation plugin.
Opens WPIDE on
Code
$wpide_field_texts = array( // Field key => array( label, placeholder ).
'billing_city' => array( 'City', '' ),
'shipping_city' => array( 'City', '' ),
'billing_address_2' => array( '', 'Flat, floor or building (optional)' ),
'billing_phone' => array( 'Mobile number', 'For delivery updates' ),
'order_comments' => array( 'Delivery notes', 'Gate code, safe place, etc.' ),
);
add_filter( 'woocommerce_checkout_fields', function ( $fields ) use ( $wpide_field_texts ) {
foreach ( $fields as $group => $group_fields ) {
foreach ( $wpide_field_texts as $key => $texts ) {
if ( ! isset( $group_fields[ $key ] ) ) {
continue;
}
if ( '' !== $texts[0] ) {
$fields[ $group ][ $key ]['label'] = $texts[0];
}
if ( '' !== $texts[1] ) {
$fields[ $group ][ $key ]['placeholder'] = $texts[1];
}
}
}
return $fields;
}, 20 );
Notes
Use full field keys such as billing_city or order_comments, and leave a value empty to keep WooCommerce's default.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.