1

I am working on checkout step for hiding the company field on the basis of customer group. can anyone help me to solve this ? Thanks

1

Create this in frontend theme->

app/design/frontend/VENDOR/NAME/Magento_Checkout/layout/checkout_index_index.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<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="mobile.top.search" remove="true"/>
        <referenceContainer name="checkout.header.wrapper">
      <container name="checkout.header.wrapper.container" htmlTag="div" htmlClass="header-wrapper-container" />
        </referenceContainer>
        <move element="logo" destination="checkout.header.wrapper.container"/>
        <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">
                                                                <item name="company" xsi:type="array">
                                                                    <item name="visible" xsi:type="boolean">true</item>
                                                                </item>
                                                          </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

hoping this should solve the issue for you

| improve this answer | |
  • I don't want to hide this for all customrrs, I want to hide this when customer group is GroupA. – Yousaf Apr 22 at 3:41
1

Another answer for this will be

Stores > Configuration > Cutomers > Customer Configuration

Name and Address Options -> Show Company -> No
| improve this answer | |

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.