Add Modules to checkout in different pages

We can add modules at the checkout screens like review, confirmation, opc. we need to mention the view files on the addModuleToStep. In this we have also added additional condition to check whether we are on right page added a sample code

var checkout = application.getComponent('Checkout');
this.opcrendered = false;
this.reviewrendered = false;
this.confirmrendered = false;
var self = this;
if (checkout) {
    checkout.on("afterShowContent", function () {
        checkout.getCurrentStep().then(function (step) {
            if ((step.url == "opc" && !self.opcrendered)) {
                self.opcrendered = true
                checkout.addModuleToStep({
                    step_url: 'opc',
                    module: {
                        id: 'TaxExemption',
                        index: 7.5,
                        classname: 'TaxExemption.View'
                    }
                });
            }
            if ((step.url == "review" && !self.reviewrendered)) {
                checkout.addModuleToStep({
                    step_url: 'review',
                    module: {
                        id: 'TaxExemption.Review',
                        index: 5,
                        classname: 'TaxExemption.Review'
                    }
                });
                self.reviewrendered = true
            }
            if ((step.url == "confirmation" && !self.confirmrendered)) {
                checkout.addModuleToStep({
                    step_url: 'confirmation',
                    module: {
                        id: 'TaxExemption.Confirmation',
                        index: 2,
                        classname: 'TaxExemption.Confirmation'
                    }
                });
                self.confirmrendered = true
            }
        })
    })
}

Leave a comment

Your email address will not be published. Required fields are marked *