2

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.

3 Answers 3

2

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

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

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);
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.

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.