Redirect Navigation to category page after Log in

As per the default SCA behavior, the My Account Overview page will be displayed after logging into the site. So we have to create an extension to perform this customization, which requires some more time and effort. We can start the development of the requirements after getting your confirmation.

_.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 (
Configuration.getRegistrationType()!=='disabled' &&
SC.ENVIRONMENT.siteSettings.siteloginrequired==='T'
) {
window.location.href=touchpoints.home;
} else {
// otherwise we need to take it to the customer center
var home=touchpoints.home;
var homeUrl=home.split("?");
var i=0;
var mainCategory=SC.CATEGORIES[i].fullurl;
var shopTouchpoint=homeUrl[0]+mainCategory+"?"+homeUrl[1];
window.location.href=shopTouchpoint;
}
}
}
});
},
})

Leave a comment

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