1

I want to disable the "new address" button from checkout page in Magento 2.
Will it be easy with the theme or create a new module?

Magento 2 - Checkout. Remove the “New Address” button from billing/shipping address with module or theme.

Please help.

1

1) Override shipping.html

-> With Custom Theme:

Copy shipping.html from vendor/magento/module-checkout/view/frontend/web/template/shipping.html

to app/design/frontend/{vendor}/{theme}/Magento_Checkout/web/template/shipping.html

-> With Custom Module:

Create requirejs-config.js app/code/{Vendor}/{Module}/view/frontend/requirejs-config.js

var config = {
    map: {
        '*': {
          'Magento_Checkout/template/shipping.html': 
              'Vendor_Module/template/shipping.html'
        }
  }
};

2) Now remove following html from shipping.html

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

3) Now run the following commands:

php bin/magento setup:static-content:deploy

php bin/magento setup:upgrade

  • i want to hide button if module is enabled? how to check and on which file? – Utsav Gupta Dec 10 '18 at 11:54
  • Do you want to check any other third party module status to hide/show New Address button? – Prince Patel Dec 10 '18 at 12:24
  • yes. i use third party module. want to check my module is enabled or not. – Utsav Gupta Dec 10 '18 at 12:55
  • Anyone have idea about it? – Utsav Gupta Dec 10 '18 at 13:35
  • Please ask another question and paste the link here in a comment to make this thread clean and clear. – Prince Patel Dec 11 '18 at 5:06
0

Try using these codes in vendor\magento\module-checkout\view\frontend\web\js\view\billing-address.js:

var lastSelectedBillingAddress = null,

countryData = customerData.get('directory-data'),
addressOptions = addressList().filter(function (address) {
    return address.getType() == 'customer-address';
});

Now, remove pub/static/frontend/*. Finally, clear the cache. You will find that the "New Address" button has been removed.

0

For hiding "New address" from billing address step in checkout. We need to override the billing-address.js from vendor\magento\module-checkout\view\frontend\web\js\view\billing-address.js and comment the below code:

addressOptions.push(newAddressOption);

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.