2

I want to disable "New Address" option from billing address drop down. here i got the code to disable it.

we just need to comment the below code : addressOptions.push(newAddressOption); and it will disable the option. but I need to override this file in my custom module and need to comment that code.

How can i override "billing-address.js" in my custom module?

Thanks.

1

2 Answers 2

4

For this, you need to create requirejs-config.js under your custom module, let say (VENDOR/MODULE/view/frontend/requirejs-config.js)

In this js file,

var config = {
    map: {
        "*": {
            "Magento_Checkout/js/view/billing-address": "VENDOR_MODULE/js/view/billing-address"
        }
    }
};

please note that VENDOR_MODULE/js/view/billing-address in this file you can write your changes (For testing purpose you can copy the original file and put some log)

After that perform static-content:deploy by executing the command from the magento2 root directory.

php bin/magento s:s:d -f

then clear the cache

php bin/magento cache:clean

1
  • Thanks @Keyur Shah & Ashish Viradiya. it working now. your both's answers work. Commented Dec 20, 2018 at 10:09
0

If there is a file that already exists that you are trying to override. Go to http\app\design\frontend\company_name\theme and in there you can create Magento_Checkout. Then as long as you get the exact file structure from where the js file is located within module-checkout. So say its within layout, create a layout folder and put it in there. Magento should use the new file instead of the default vendor file.

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.