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

Docs describing how to retrieve a cart with ReactJS not clear #7165

Closed
1 of 2 tasks
joeldodich opened this issue Apr 28, 2024 · 3 comments
Closed
1 of 2 tasks

Docs describing how to retrieve a cart with ReactJS not clear #7165

joeldodich opened this issue Apr 28, 2024 · 3 comments

Comments

@joeldodich
Copy link

Preliminary Checks

Issue Summary

https://docs.medusajs.com/modules/carts-and-checkout/storefront/implement-cart

It is not very clear how the react cart component knows what cart to retrieve. There is a note about a path paramenter, but I could not find details describing what that parameter should be called or how to implement.

How can this issue be resolved?

  1. Update to reflect suggested implementation

...

Are you interested in working on this issue?

  • I would like to fix this issue
@shahednasser
Copy link
Member

As mentioned in the create a cart section, the cart ID is saved in the localstorage. So, in your code you can check for it whenever necessary (such as to retrieve the cart). Once the order is placed or the customer logs out, you have to clear the cart ID from the local storage (which is also mentioned in the retrieve cart section.)

@joeldodich
Copy link
Author

@shahednasser I guess what was unclear is that vanilla JS code example, the user has to pass a cart_id which matches the ID saved in the previous step you mention. In the ReactJS code, there is no reference to how the hook interacts with the local variable. Does it need to be the variable same name? Can I pass a different name? Do I need to use a separate hook to get the cart using the ID then can use the cart object?

As someone who is reading the docs and trying to put it all together, this is not clear to me. If you feel this is all implied and obvious, feel free to leave unchanged.

@shahednasser
Copy link
Member

Can you specify which section you mean?

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

No branches or pull requests

2 participants