Created
April 11, 2013 13:24
-
-
Save makfruit/5363335 to your computer and use it in GitHub Desktop.
A drop-in HTML/JS script for Ecwid to force logout after an order is placed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
// A drop-in HTML/JS script for Ecwid to force logout after an order is placed | |
if (typeof(Ecwid) == 'object') { | |
Ecwid.OnPageLoaded.add(function(page) { | |
if ('ORDER_CONFIRMATION' == page.type) { | |
var localStoragePrefix = 'PSecwid__' + Ecwid.getOwnerId() + 'PS'; | |
var isLoggedIn = (localStorage.getItem(localStoragePrefix + 'token') != null); | |
if (isLoggedIn) { | |
var itemsToRemove = ['token','customerid','profile']; | |
for (var i = 0; i < itemsToRemove.length; i++) { | |
localStorage.removeItem(localStoragePrefix + itemsToRemove[i]); | |
} | |
window.location.reload(true); | |
} | |
} | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Is there any way this code could also clear the cart?
I have a client running Ecwid in a shop kiosk.
I use this code to sign out and start a new session every time the home page is loaded, and need to clear the cart/basket too if possible.
EDIT - I figured out how to do this. Here is a modified version that also clears the cart regardless of the user being signed in:
Thanks,
Ian