Checkout page: cannot make zip code and city field to appear next to each other
-
I imported your Megamarket demo.
I applied regular WooCommerce snippet code in order to adapt the billing fields form on the checkout page:
add_filter( 'woocommerce_checkout_fields', 'customize_billing_fields' );
function customize_billing_fields( $fields ) {
// Remove billing_address_2 field
if ( isset( $fields['billing']['billing_address_2'] ) ) {
unset( $fields['billing']['billing_address_2'] );
}
// Remove billing_state field
if ( isset( $fields['billing']['billing_state'] ) ) {
unset( $fields['billing']['billing_state'] );
}
// Make billing_phone field optional
if ( isset( $fields['billing']['billing_phone'] ) ) {
$fields['billing']['billing_phone']['required'] = false;
}
// Display billing_postcode and billing_city fields in the same row
if ( isset( $fields['billing']['billing_postcode'] ) && isset( $fields['billing']['billing_city'] ) ) {
$fields['billing']['billing_postcode']['class'] = array( 'form-row-first' );
$fields['billing']['billing_city']['class'] = array( 'form-row-last' );
}
return $fields;
}
My goal:
Having the zip code field and city field to appear next to each other.
Actual result:
Despite the snippet both fields still have 100% width each. I assume because of your theme.
I recorded a screencast for you, see attached.
Zip code field = “Postleitzahl”, city field = “Stadt”
Very strange: You will see in second 00:04, for half a second it is visible that the zip code field and city field appear next to each other.
Hello,
Can you kindly verify if it operates properly with common WordPress themes such as TwentyTwenty or WooCommerce Storefront? This will help determine if the problem lies with our theme or not.
Looking forward to hearing back from you!
Kind Regards.