Magento 2 Checkout – Remove ‘New Address’ from Billing Address Dropdown

checkoutmagento2

I am trying to remove the "New Address" option in the billing address select.
(I don't want customers to be able to add a new billing address).

enter image description here

I have tried hiding it via css: select[name="billing_address_id"]:last-child { display:none; } and also by jQuery: $("select[name=billing_address_id] option:last").remove();

I have also tried removing it from vendor\magento\module-checkout\view\frontend\web\js\view\billing-address.js:

        var lastSelectedBillingAddress = null,
        //newAddressOption = {
            /**
             * Get new address label
             * @returns {String}
             */
        //    getAddressInline: function () {
        //        return $t('New Address');
        //    },
        //    customerAddressId: null
        //},
        countryData = customerData.get('directory-data'),
        addressOptions = addressList().filter(function (address) {
            return address.getType() == 'customer-address';
        });

    addressOptions.push(newAddressOption);

But all 3 solutions have failed.

(of course I have refreshed the cache, deployed static content, deleted pub/static/frontend/*)

Anyone have a clue?

Thanks

Best Answer

Your following solution must be work: I have also tried removing it from vendor\magento\module-checkout\view\frontend\web\js\view\billing-address.js:

Replace following code:


var lastSelectedBillingAddress = null,

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

//addressOptions.push(newAddressOption);

Also remove pub/static/frontend/* and clear cache.

NB: Don't modify core code directly.