0

enter image description here

Magento 2 - Checkout. Remove “New Address” Button from checkout billing/shipping address with module for B2B customers

2 Answers 2

0

Try these all steps

Step 1: Create the module structure In the app/code directory of your Magento installation.

  - app
  - code
    - Vendor
      - Module
        - etc
          - module.xml
        - registration.php

Step 2: Create the module declaration file Create the module.xml file in the etc

  <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="1.0.0" />
</config>

Step 3: Create the registration file Create the registration.php

  <?php
use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(
    ComponentRegistrar::MODULE,
    'Vendor_Module',
    __DIR__
);

Step 4: Override the checkout layout file Create the following file in your module's directory: app/code/Vendor/Module/view/frontend/layout/checkout_index_index.xml

  <?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="customer-addresses">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="checkout.steps.billing-step.billingAddress.customer-addresses" xsi:type="array">
                            <item name="config" xsi:type="array">
                                <item name="componentDisabled" xsi:type="boolean">true</item>
                            </item>
                        </item>
                        <item name="checkout.steps.shipping-step.shippingAddress.customer-addresses" xsi:type="array">
                            <item name="config" xsi:type="array">
                                <item name="componentDisabled" xsi:type="boolean">true</item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

Step 5: Enable the module

  php bin/magento module:enable Vendor_Module

  php bin/magento setup:upgrade

  php bin/magento setup:di:compile

  php bin/magento cache:clean
3
  • I want to hide this button for B2B and show this button for B2C how I can handle this any suggestions, please Commented Jun 3, 2023 at 18:43
  • this code is not worked Commented Jun 3, 2023 at 19:08
  • How you have identified that a customer is B2C or B2B customer?
    – Amit Bera
    Commented Jun 4, 2023 at 6:32
0

Please copy the file from vendor/magento/module-checkout/view/frontend/web/template/shipping.html

to

app/design/frontend/<theme_dir>/Magento_Checkout/web/template/shipping.html

Remove the below code from the file

<!-- Address form pop up -->
        <if args="!isFormInline">
            <div class="new-address-popup">
                <button type="button"
                        class="action action-show-popup"
                        click="showFormPopUp"
                        visible="!isNewAddressAdded()">
                    <span translate="'New Address'"></span>
                </button>
            </div>
            <div id="opc-new-shipping-address"
                 visible="isFormPopUpVisible()"
                 render="shippingFormTemplate"></div>
        </if>
0

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.