• Skip to primary navigation
  • Skip to content
  • Skip to footer

RedChamps

RedChamps Blog

Main navigation

  • Magento 1 Extensions
  • Magento 2 Extensions
  • Visit Store

Magento 2: Reorder country, state, city fields in address form

Programming, Steps · December 27, 2017

We recently received custom development request to change the sequence of the country, state and city input fields in checkout address form. The default sequence of these fields is:

1. City
2. State
3. Country

The request is to reverse it i.e

1. Country
2. State
3. City

We are sharing process mentioning what needs to be adjusted in Magento 2 core.

@Developers: Please find a proper way to do this without directly changing Magento core files
@Non-developers: Please find a developer to do these changes without directly changing Magento core files or email us at [email protected] if you would like us to do this for you.

1. Change sort order of country field for shipping address form

Open file vendor/magento/module-checkout/view/frontend/layout/checkout_index_index.xml

search for the line

<item name=”country_id” xsi:type=”array”>

replace next line

<item name=”sortOrder” xsi:type=”string”>115</item>

with

<item name=”sortOrder” xsi:type=”null”/>

2. Change sort order of country field for billing address form

Open file vendor/magento/module-checkout/Block/Checkout/LayoutProcessor.php

search for the line

‘country_id’ => [

replace next line

‘sortOrder’ => 115,

with

‘sortOrder’ => null,

3. Change sort order of city field

Open database table customer_eav_attribute and change sort order of ‘city’ (attribute id 29) to a higher value

  • Facebook
  • Twitter
  • Google+

Filed Under: Programming, Steps

Rav

Founder and Magento Certified Developer at RedChamps

Footer

Follow Us ON

  • Facebook
  • Twitter
Copyright © 2025 • Powered by RedChamps