Does anyone know how I can get the cart to empty when the user closes their browser? I have tried adding this to the footer:
<script type="text/javascript">
function del_cookie(cart) {
document.cookie = cart +
'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}
</script>
and adding
onload="SetCookie()" onunload="del_cookie()"
to the body tag in theme.liquid but it doesn't work. I'm not sure where I'm going wrong. If anyone can help that would be much appreciated!
Hey Peeps.
This might be possible with Javascript, but rather than deleting the Cookie I would see about running a
https://Your-URL-Here/cart/clear
The issue with this though, is your possibly removing Shopify's ability to do abandoned carts. Meaning no email sent to say "Hey you had stuff in your cart!"
This could lead to lost sales.
Thanks for your suggestion! I'm not sure what you mean by running a Your-URL-Here/cart/clear though.
From what I've read on Shopify this would be linked to from a button that the user clicks. How would you implement this just when the user closes their browser with no other action on their part?
Thanks!
User | Count |
---|---|
25 | |
22 | |
22 | |
19 | |
12 |