0

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.

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>
  • 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. – Vinod Kumar Jul 13 '18 at 7:32
  • @VinodKumar did you find the solution for your error?. I'm also getting that error, please share your solution here.. – Ask Bytes Dec 1 '18 at 7:07
0

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>

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.