2

I tried to hide the country field in the checkout page and billing page. Here's my code :

<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 name="country_id" xsi:type="array">
    <item name="visible" xsi:type="boolean">false</item>
</item>

I could do checkout when i remove this code :

<item name="country_id" xsi:type="array">
    <item name="visible" xsi:type="boolean">false</item>
</item>

But, when i remove it, the country field still appeared. How can i hide the country field? I can't hide with CSS because the class for country field is class="field _required"

  • why do you want to remove? – Amit Bera Sep 28 '18 at 4:20
  • cause it's only in my country, and it should be default choose only 1 country – Edwin Widhiyanto Sep 28 '18 at 6:10
3

You can do this using plugin:

  $visible = [
       'visible' => false
       ];

  $country = &$jsLayout['components']['checkout']['children']['steps'] 
 ['children']['shipping-step']
['children']['shippingAddress']['children']['shipping-address-fieldset'] 
 ['children']['country_id'];

  $street = array_merge($country, $visible);
  • 1
    @AdityaShah @ Rutvee please be kind to each other. You are both wonderful people for helping out others with answers to their questions – Sander Mangel Sep 28 '18 at 9:42
  • hi @RutveeSojitra, i tried your pluggin, but it made the checkout page just blank, is there something wrong i did? – Edwin Widhiyanto Oct 1 '18 at 7:09
  • It's work for me, you just need to pass ['children']['company']['visible'] = false if you want to hide company field. +1 for this :) – Chirag Patel Sep 3 at 10:36

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.