0

I am trying to modify the default Magento 2 Checkout, basically I want to remove the "Payment and Review" step and put them all together.

Everything goes well but I have stuck intro an issue.

I want to modify the shipping.js file and make the selectShippingMethod() function to call the setShippingInformation(). Basically instead of the "Next" button I want to submit the data when shipping carrier got selected.

I have this fragment of code:

/**
         * @param {Object} shippingMethod
         * @return {Boolean}
         */
        selectShippingMethod: function (shippingMethod) {
            var self = this;
            selectShippingMethodAction(shippingMethod);
            checkoutData.setSelectedShippingRate(shippingMethod['carrier_code'] + '_' + shippingMethod['method_code']);
            self.shippingInformations(); // <- THERE.......
            return true;
        },

        shippingInformations: function () {
           console.log('test');
        },

        /**
         * Set shipping information handler
         */
        setShippingInformation: function () {
            if (this.validateShippingInformation()) {
                quote.billingAddress(null);
                checkoutDataResolver.resolveBillingAddress();
                registry.async('checkoutProvider')(function (checkoutProvider) {
                    var shippingAddressData = checkoutData.getShippingAddressFromData();

                    if (shippingAddressData) {
                        checkoutProvider.set(
                            'shippingAddress',
                            $.extend(true, {}, checkoutProvider.get('shippingAddress'), shippingAddressData)
                        );
                    }
                });
                setShippingInformationAction().done(
                    function () {
                        stepNavigator.next();
                    }
                );
            }
        },

When I call any function like that self.shippingInformations(); I just got an error: caught TypeError: self.shippingInformations is not a function.

I want to call the setShippingInformation() function but still have the same issue. What I am missing?

0

Your Answer

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