How to prevent customers from placing orders when the customer chooses Alaska or Hawaii states the shipping sates in shipping address.

We can restrict delivery methods in NetSuite by removing states in the delivery method; we can also prevent customers without making any changes in NetSuite only by using extension.

JavaScript:

Modules: “Wizard.View” (WizardView), “SC.ComponentContainer” (ComponentContainer)

_.extend(WizardView.prototype, {
submit: function (e) {
        try {
            let self = this;
            if (self.wizard.getCurrentStep().step_url === 'shipping/address' || self.wizard.getCurrentStep().step_url === 'review') {
                let cart = ComponentContainer.getComponent('Cart');
                cart.getShipAddress().then(function(shipaddress) {
                    if (shipaddress.country === 'US' && (shipaddress.state === 'AK' || shipaddress.state === 'HI')) {
                        let message = Configuration.get('invalidStates.message');
                        self.showError(message ? message : 'We are unable to ship for the Alaska and Hawaii states.');
                    } else {
                        self.wizard.getCurrentStep().submit(e);
                    }
                })
            } else {
                self.wizard.getCurrentStep().submit(e);
            }
        } catch (error) {
            console.error('Error @ submit', error);
        }
    },				
});

Leave a comment

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