Put Postcode and City on One Row
Places the postcode and city fields side by side on the checkout, which saves space and matches how many countries write addresses.
Opens WPIDE on
Code
add_filter( 'woocommerce_default_address_fields', function ( $fields ) {
if ( isset( $fields['postcode'], $fields['city'] ) ) {
$fields['postcode']['class'] = array( 'form-row-first', 'address-field' );
$fields['city']['class'] = array( 'form-row-last', 'address-field' );
$fields['city']['priority'] = $fields['postcode']['priority'] + 1;
}
return $fields;
}, 30 );
Notes
On phones the two fields still stack, as with WooCommerce's first and last name fields.
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.