0

I would like turn all my js overwrites into mixins. I'm trying to create a mixin for the following file:

view/frontend/web/js/action/place-order.js

But the function in there doesn't have a name

' return function (paymentData, messageContainer) {'

When googling and checking magento 2 docs I can't find anything about how to turn a function without a name into a mixin. Anyone have an idea?

| improve this question | | | | |
0

I will assume you use extra module for purpose customises on place order js

In module you need define file requirejs-config.js

path

app\code\YourVendor\ModuleName\view\frontend\requirejs-config.js


Content

var config = {
     config: {
       mixins: {
        'Magento_Checkout/js/action/place-order': {
            'YourVendor_ModuleName/js/action/place-order-mixin': true
            }
        }
     }
};

file YourVendor_ModuleName/js/action/place-order-mixin

define([
 'jquery',
 'mage/utils/wrapper'
], function ($, wrapper) {
   'use strict';

    return function (placeOrderAction) {

      /** Override default place order action */
       return wrapper.wrap(placeOrderAction, function (originalAction, paymentData, messageContainer) {
          //Your extras logic here
          //Add extended functionality here

          return originalAction(paymentData, messageContainer);
      });
    };
});
| improve this answer | | | | |

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.