How to override



You can override it into your module or theme.

How Into your theme :

create requirejs-config.js file into your theme root folder and add following code:

var config = {
    map: {
        "*": {            
            "Magento_OfflinePayments/js/view/payment/method-renderer/cashondelivery-method": "js/override/view/payment/method-renderer/cashondelivery-method"

then create following path folders into your theme from root:


and add that js file into this created folder.


How Into your module

create requirejs-config.js file into Your Module :


and add this :

var config = {
    map: {
        '*': {

Also don't forget to run deploy command after override file php bin/magento setup:static-content:deploy php bin/magento setup:upgrade php bin/magento cache:flush


  • I need to add custom function in that file ....so can i use map or mixins – Mahi M Mar 1 '18 at 13:26
  • i think you should use map, because a mixin is a class whose methods are added to, or mixed in, with another class. This allows you to return a new instance of the target component with your modifications attached to it before it is used in the application. – Hardik Patel Mar 5 '18 at 8:19

To override Magento_OfflinePayments/js/view/payment/method-renderer/cashondelivery-method.js in your theme, just copy the file and place under theme in the same path as above and run the following command after that:

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento cache:clean

This will work :)


Use Mixin instead of Map.

In your require-js add below code.

 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.

var config = {
 config: {
     mixins: {
         'Magento_OfflinePayments/js/cashondelivery-method': {
             'Namespace_Modeulename/js/cashondelivery-method': true


], function ($, url) {
    'use strict';

    return function (widget) {
        $.widget('mage.cashondelivery', widget, {

        return $.mage.cashondelivery;

I hope it helps!

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.