Magento – City dropdown at checkout magento 2

checkoutmagento2

I use magento 2.0.7 is it possible to custom the checkout page city field(text) to dropdown list?

Best Answer

Yes.

The easiest would be to add a new entity where the values for your cities are stored. In the frontend, just change the input type to dropdown and load the list of cities. When a user selects a field from the dropdown, store the text value (as it is now). You could even do a check if the selected city is a valid one from your city list before storing the data. This way you don't have to change a lot.

A more advanced approach (if needed) would be to also add relations to the directory_country and/or directory_country_region tables to only show cities which belong to the specific country or region selected in the checkout.

Related Topic