0

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>

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 added your <item name="default" xsi:type="string">abc</item> into <item name="region_id" xsi:type="array"> but still the same problem. – user2089098 Dec 10 '17 at 16:11
1

Go to the Admin side, click the 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. I was able at least to select one country. This time on checkout get: Some addresses cannot be used due to country-specific configurations. – user2089098 Dec 10 '17 at 17:12
  • I sniffed queries from M2 into DB. And I saw that require region is set in core_config_data table. So I changed proper value directly: UPDATE core_config_data SET value=NULL where config_id=12; . Still doesnt work... Still get "Some addresses cannot be used due to country-specific configurations" – user2089098 Dec 10 '17 at 17:50

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.