cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2: "regionId is a required field."

Magento 2: "regionId is a required field."

Im using Magento 2.2.1 and I try to customize checkout module. In order to remove unnecessary fields I added/overrided file in:

app/design/frontend/custom_template/template1/Magento_Checkout/layout/checkout_index_index.xml

with:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="checkout.root">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="checkout" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="steps" xsi:type="array">
                                    <item name="children" xsi:type="array">
                                        <item name="shipping-step" xsi:type="array">
                                            <item name="children" xsi:type="array">
                                                <item name="shippingAddress" xsi:type="array">
                                                    <item name="children" xsi:type="array">
                                                        <!-- The name of the form the field belongs to -->
                                                        <item name="shipping-address-fieldset" xsi:type="array">
                                                            <item name="children" xsi:type="array">
                                                                <!--Remove fields-->
                                                                <item name="region_id" xsi:type="array">
                                                                    <item name="component" xsi:type="string">Magento_Ui/js/form/element/region</item>
                                                                    <item name="visible" xsi:type="boolean">false</item>
                                                                    <item name="config" xsi:type="array">
                                                                        <item name="componentDisabled" xsi:type="boolean">true</item>
                                                                    </item>
                                                                    <item name="validation" xsi:type="array">
                                                                        <item name="required-entry" xsi:type="boolean">false</item>
                                                                    </item>
                                                                </item>
                                                                <item name="company" xsi:type="array">
                                                                    <item name="visible" xsi:type="boolean">false</item>
                                                                </item>
                                                                <item name="country_id" xsi:type="array">
                                                                    <item name="visible" xsi:type="boolean">false</item>
                                                                    <item name="config" xsi:type="array">
                                                                        <item name="componentDisabled" xsi:type="boolean">true</item>
                                                                    </item>
                                                                </item>
                                                                <item name="telephone" xsi:type="array">
                                                                    <item name="visible" xsi:type="boolean">false</item>
                                                                    <item name="config" xsi:type="array">
                                                                        <item name="componentDisabled" xsi:type="boolean">true</item>
                                                                    </item>
                                                                </item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>


Unnecessary fields disappeared (even telephone stop being required) but on the last step of checkout (http://store.com/checkout/#payment) when I click button "Place Order" i get

"regionId is a required field" and I cant complete the order.

 

How Can I disable this field entirely?

 

I tried also:

  1. Add <item name="default" xsi:type="string">something</item> into <item name="region_id" xsi:type="array"> 
  2. From Stores => General => State Option. From the list, unselect all the selected countries. Save config, clear your cache and refresh. It seems impossibe to unselect all selected countries. If I unselect all countries and save configuration then it leaves last configuration. So I changed configuration directly in DB: UPDATE core_config_data SET value=NULL where config_id=12; - this time I get: Some addresses cannot be used due to country-specific configurations