All things Shopify and commerce
Greetings,
I'm currently struggling with finding a way to detect whether a customer just logged in. My goal is to display a bootstrap dialog with certain message whenever it happens. Using customer.id is not a good solution since I only want it to be shown once per log in event.
Currently the only solution I could come up with was to use local storage to determine whether dialog was already shown
const isModalDisabled = !!localStorage.getItem('isModalDisabled');
const isLoggedIn = !!{{customer.id}}
if(isLoggedIn && isModalDisabled){
$('#addCartItemsToStreamModal').modal('show');
localStorage.setItem('isModalDisabled', true)
}
I remove this value whenever customer is not logged in:
if (!isLoggedIn) {
localStorage.removeItem('isModalDisabled');
}
While it does work it is not the best way of handling the problem I think. Is there anything that shopify offers to make this more reliable like some action listener listening to log in events that we can subscribe to?
Any help would be highly appreciated 🙂
Hey !
Got any solution or not?
I am also stuck there...
Please Guide me if you got the solution.
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024