StoreHippo allows you to set up the functionality to remember the user-selected substore. This functionality allows your store to remember the previously selected substore of the particular user.
Suppose your store has three substores, which are Substore1, Substore2, and Substore3. Now, if any particular user has selected Substore2, you want Substore2 to be pre-selected whenever that user visits the site.
To achieve this, follow the steps given below:
ms.bind('ms.page_loaded', function (event) {
if (ms.substore && ms.substore.alias) {
localStorage.setItem("substore", ms.substore.alias)
}
if (ms.substore || !localStorage.getItem("substore") || !localStorage.getItem("substore").length) {
return;
}
var req = {
entity: 'ms.settings',
customCommandName: '',
data: {
"store": localStorage.getItem("substore")
}
}
ms.app.call('setPreferences', req, function (err, response) {
if (!err) location.reload();
})
})
Now, the store which was selected by the user previously will be auto-selected.