1

I want to remove city field from the shipping and billing form on the checkout page. I have checked in checkout_index_index.xml in my theme or vendor but I didn't find the city field.

Give me suggestion to remove City field.

2 Answers 2

1

This is the correct syntax to disable the City field without breaking anything else, following the "disable a component documentation"

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" 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">
                                                    <item name="shipping-address-fieldset" xsi:type="array">
                                                        <item name="children" xsi:type="array">
                                                            <item name="city" xsi:type="array">
                                                                <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>

1
  • I added checout_index_index.xml file in my them but not working. Commented Nov 29, 2019 at 8:56
0

Try with following code in checkout_index_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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="billing-step" xsi:type="array">
                                <item name="children" xsi:type="array">
                                    <item name="billingAddress" xsi:type="array">
                                        <item name="children" xsi:type="array">
                                             <!-- The name of the form the field belongs to -->
                                                <item name="billing -address-fieldset" xsi:type="array">
                                                    <item name="children" xsi:type="array">
                                                        <!--Remove fields-->
                                                        <item name="city" xsi:type="array">
                                                            <item name="visible" xsi:type="boolean">false</item>
                                                        </item>
                                                    </item>
                                                </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                            <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="city" xsi:type="array">
                                                        <item name="visible" xsi:type="boolean">false</item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </item>
            </item>
        </item>
    </argument>
   </arguments>
  </referenceBlock>
 </body>
</page>
2
  • after using this code, city field has removed but getting error on placing order. Error: an error occured on server. Please try again to order place. Commented Jul 13, 2018 at 7:32
  • @VinodKumar did you find the solution for your error?. I'm also getting that error, please share your solution here..
    – Ask Xah
    Commented Dec 1, 2018 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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