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?

asked Feb 11, 2020 at 13:34

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);
 });
 };
});
answered Feb 11, 2020 at 14:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.