Redirect To Homepage When Customer Logs

The code is added below for redirect to the homepage when the customer Logs in to the Website.

_.extend(LoginRegisterLoginView.prototype, {

					redirect: function (context, response) {
						const url_options = Utils.parseUrlOptions(window.location.search);
						const { touchpoints } = response;
						const isPasswordReset = url_options.passwdret;
						const self = this;

						// Track Login Event
						this.trackEvent(function () {
							if (
								!isPasswordReset &&
								(url_options.is === 'checkout' || url_options.origin === 'checkout')
							) {
								self.refreshApplication(response);
							} else {
								// if we know from which touchpoint the user is coming from
								if (url_options.origin && touchpoints[url_options.origin]) {
									// we save the URL to that touchpoint
									let url = touchpoints[url_options.origin];
									// if there is an specific hash
									if (url_options.origin_hash) {
										// we add it to the URL as a fragment

										url = Utils.addParamsToUrl(url, { fragment: url_options.origin_hash });
									}

									window.location.href = url;
								} else {

									// We've got to disable passwordProtectedSite feature if customer registration is disabled.
									if (
										SC.CONFIGURATION.getRegistrationType() !== 'disabled' &&
										SC.ENVIRONMENT.siteSettings.siteloginrequired === 'T'
									) {

										window.location.href = touchpoints.home;
									} else {

										// otherwise we need to take it to the customer center
										window.location.href = touchpoints.home;
									}
								}
							}
						});
					},
				})

Leave a comment

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