4

I'm struggling to override or get in the middle of some checkout action scripts, for example the place-order method of app/code/Magento/Checkout/view/frontend/web/js/view/review.js

I can see there is a "beforePlaceOrder" variable in there but I'm unsure how to subscribe my own method there.

2 Answers 2

1

If you need to overwrite a function instead a class method (I used to overwrite Magento_Checkout/js/action/place-order).

requirejs-config.js

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

place-order.js

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

    return function (placeOrderAction) {
        return wrapper.wrap(placeOrderAction, function (originalAction, paymentData, redirectOnSuccess) {
            // my own code here
            return originalAction(paymentData, redirectOnSuccess);
        });
    };
});
4

The code you described is not in magento 2 anymore. Checkout has been modified.

You can substitute any action (and any requireJs component) using requireJs map configuration (http://requirejs.org/docs/api.html#config-map) in magento requireJs config files.

Interception (or mixins) feature is not yet implemented for JS) but it's in development right now and will be delivered pretty soon.

0

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.