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