-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
loadCart not merging correctly #192
Comments
hey @amirhemm, which version of USC are you using? The beta or the latest release? |
I'm using the latest release. |
Hey @amirhemm, sorry for taking so long to get back to you. Did you end up finding a workaround by any chance? I am thinking of taking the merge approach you proposed, but there were some other issues/questions that came about regarding loadCart so I didn't get around to it. |
Hi @dayhaysoos, no worries, I know you got a lot on your plate. Well I did manage to set something up for my use case. In a nutshell, if they user is logged in I merge (not by using the utility function, I made my own helper function) their DB cart with local storage cart. Everything works fine if user adds a new item to the cart. But once a user adds an item which is already added before to the DB cart, I set the quantity of the remote cart as the source of truth. I don't add the quantities. I just overwrite the whole remote item with the local item. I hope that help. Let me know know if you have a question. I also have a test site up. Let me know if you are interested to check it out. |
@amirhemm I would love to see it! I would definitely like some direction on how to implement this with |
@dayhaysoos you can check out a sample implementation here. Let me know if come across any questions, I'll be more that happy to help if needed. |
Hi,
I'm trying to use this method to sync my DB with local storage with the loadCart method and merging to true, but it seems that if you have the same product with the same ID added and you are trying to load it from DB and it already exists in the local storage, the current behavior is that the cartCount and totalPrice update accordingly but the cartItem quantity is not being updated.
Can you verify that this issue exists and if it dose I would suggest one of the these two approaches to fix it:
Thanks
The text was updated successfully, but these errors were encountered: