Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo version on vercel doesn't 'always' update cart #26

Open
psntr opened this issue Feb 11, 2023 · 2 comments
Open

Demo version on vercel doesn't 'always' update cart #26

psntr opened this issue Feb 11, 2023 · 2 comments

Comments

@psntr
Copy link

psntr commented Feb 11, 2023

Strange enough, if you open your browser in private mode and add the first product "Quarter Zip" to your cart and then within the cart side modal, the buttons (remove / or add more item) don't work. It send requests but do not update the cart value.

@psntr
Copy link
Author

psntr commented Mar 9, 2023

For those who experienced similar issue, I found a quick fix:

Add this line:
cartId = JSON.parse(localStorage.getItem('cartId'));
in src/routes/+layout.svelte after
await callCreateCart(); in line 27.

Explanation, on first load, there is no cartId, so the variable cartId is null:

if (cartId === 'undefined' || cartId === null || cartIdExpired) {
        await callCreateCart();
}

The await callCreateCart(); creates a new cartId but do not re-assign it to the variable cartId after it's been created therefore the cart didn't update because we sent a null value but once we re-assign it right after the await callCreateCart(), the cart responds correctly.

Hope you guys can add this @leerob / @StephDietz / @dominikg

@dominikg
Copy link
Contributor

I prefer not being @ mentioned in random issues of repositories i made one completely unrelated contribution to. thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants