9

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

  • oyenetwork.com/articles/… this explains how to add delivery date in checkout process, you can use same method to add city drop down. Hope that helps – Ekta Puri Aug 4 '16 at 22:15
8
+50

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.

3

for the sesion of estimate shipping and Tax of magento you will need overwrite of the class \Magento\Checkout\Block\Cart\LayoutProcessor.

 $elements = [
        'city' => [
            'visible' => true,
            'formElement' => 'select',
            'label' => __('City'),
            'value' =>  '',
            'options' => array_option(),
        ],

enter image description here

  • 2
    can you provide tutorial code/github link for this – matinict Jul 5 '18 at 8:02
  • Can you please provide a code here – Ask Bytes Dec 1 '18 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.