1

I am trying to override

Magento_Braintree/js/view/payment/method-renderer/cc-form

But i am not getting any progress. I have tried map

'Magento_Braintree/js/view/payment/method-renderer/cc-form': 'module_name/js/view/payment/method-renderer/cc-form-mixin'

mixins:

'Magento_Braintree/js/view/payment/method-renderer/cc-form': {
'module_name/js/view/payment/method-renderer/cc-form-mixin': true

Anyone know how to solve this any help or advice

2 Answers 2

2

If you want to override the Magento JS core and replace it by your custom Javascript.

Step 1: Create a RequireJS configuration file requirejs-config.js

var config = {
  "map": {
    "*": {
      "<default_component>": "<custom_component>"
    }
  }
};
  • Where the following notation is used:

<default_component>: the name of the default component you replace

<custom_component>: the name of the custom component

Example, if you want to use custom navigation-menu.js script instead of the default menu widgets, your requirejs-config.js should contain the following:

var config = {
  "map": {
    "*": {
      "menu": "/js/navigation-menu",
      "mage/backend/menu": "js/navigation-menu",
    }
  }
};

Step 2: Place your requirejs-config.js file in one of the following directories (it depends on the location of your custom script):

  • Your theme files:
  • Your module view files: /view/frontend

The 2 steps I mention above is the shortest process for you to Override Magento JS Core in Magento 2. With this guide, you can manage the Magento JS Core in Magento 2 easily. Every store has a Magento JS Core in Magento 2 with many attributes.

I hope this will help

1
  • @ Muhammad Hasham. I have tried this Steps i took => app/code/modukle_name/view/frontend/requirejs-config.js 'Magento_Braintree/js/view/payment/method-renderer/cc-form': 'Module_Name/js/view/payment/method-renderer/cc-form' but its not picking up when i check frontend i get the following error "ReferenceError: Unable to process binding "text: function()....." Commented Jul 23, 2019 at 9:26
2

Found the answer

var config = {
    config: {
        mixins: {
            '[core_module_name]/js/view/payment/method-renderer/cc-form': {
                '[module_name]/js/view/payment/method-renderer/cc-form': true
            },
        }
    }

map is to override the entire JS mixins to extend

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.