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?

1 Answer 1

2

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);
      });
    };
});

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.