2

I'm having trouble with mixin in Magento 2. I would like to override the following file to edit a function.

Magento_Checkout/web/js/model/new-customer-address.js:

define([
        'underscore'
    ], function (_) {
        'use strict';

        /**
         * @param {Object} addressData
         * Returns new address object
         */
        return function (addressData) {
            // ...

            return {
                // .....

                isEditable: function () {
                    return true;
                }

                // ....
            }
        }
    });

I would like to edit isEditable function so I have:

isEditable: function () {
    return addressData.is_editable !== undefined && addressData.is_editable == true;
}

I'm trying to extend it with a mixin like this:

define(function () {
    'use strict';
return function (target) { // target == Result that Magento_Checkout/js/model/new-customer-address' returns.
    console.log(target.addressData); // Undefined
    return target;
};
});

Can someone tell me where I'm wrong please ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.