3

I tried to disable the country field in checkout but i can't.

I already disable few fields like company on checkout page by adding this this

<item name="visible" xsi:type="boolean">false</item> code in module_checkout/layout/checkout_index_index.xml.

<item name="company" xsi:type="array">
   <item name="visible" xsi:type="boolean">false</item>
    <item name="validation" xsi:type="array">
     <item name="min_text_length" xsi:type="number">0</item>
    </item>
</item>

If i try to do the same thing for country filed, this field dosen't disappear.

Does anyone know if it's any other solution for disable this field?

5
  • 1
  • i already add <item name="visible" xsi:type="boolean">false</item> for disable the filed, and it's not working. Feb 17, 2017 at 8:03
  • Did You add <item name="componentDisabled"? Feb 17, 2017 at 8:06
  • there are 2 country filed in checkout_index_index.xml <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> and this one <item name="country_id" xsi:type="array"> </item> Feb 17, 2017 at 8:12
  • in which one i need to add this line <item name="visible" xsi:type="boolean">false</item>? Feb 17, 2017 at 8:13

4 Answers 4

1

First select default country from admin then, using css

 div[name="shippingAddress.country_id"] {
    display: none;
}
0

I had same problem. Solved it with this code:

app/design/frontend/Vendor/theme/Magento_Checkout/layout/checkout_cart_index.xml

<referenceBlock name="checkout.cart.shipping">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="block-summary" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="block-shipping" xsi:type="array">
                                    <item name="children" xsi:type="array">
                                        <item name="address-fieldsets" xsi:type="array">
                                            <item name="children" xsi:type="array">
                                                <item name="country_id" xsi:type="array">
                                                    <item name="visible" xsi:type="boolean">false</item>
                                                </item>
                                                <item name="region_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>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
</referenceBlock>
0

It should disappear by following:

<item name="country_id" xsi:type="array">
    <item name="visible" xsi:type="boolean">false</item>
</item>
1
  • using this way region/state filed also get hidden. But state field required here and country fields should be hidden.
    – Manish
    Jun 27, 2018 at 16:05
0
<item name="region_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>
1
  • Do let me know if you face any issue.
    – mighty_hk
    Jun 30, 2018 at 9:39

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.