0

How can we add country and state dropdown in custom checkout form. I tried below in checkout_index_index layout xml file but it is not working.

....    
<item name="country_id" xsi:type="array">
    <item name="sortOrder" xsi:type="string">1</item>
</item>
<item name="region" xsi:type="array">
    <item name="visible" xsi:type="boolean">false</item>
    <item name="sortOrder" xsi:type="string">2</item>
</item>
<item name="region_id" xsi:type="array">
    <item name="component" xsi:type="string">Magento_Ui/js/form/element/region</item>
    <item name="config" xsi:type="array">
        <item name="template" xsi:type="string">ui/form/field</item>
        <item name="elementTmpl" xsi:type="string">ui/form/element/select</item>
        <item name="customEntry" xsi:type="string">shippingAddress.region</item>
    </item>
    <item name="validation" xsi:type="array">
        <item name="required-entry" xsi:type="boolean">true</item>
    </item>
    <item name="filterBy" xsi:type="array">
        <item name="target" xsi:type="string"><![CDATA[${ $.provider }:${ $.parentScope }.country_id]]></item>
        <item name="field" xsi:type="string">country_id</item>
    </item>
    <item name="sortOrder" xsi:type="string">3</item>
</item>
....

Your Answer

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

Browse other questions tagged or ask your own question.