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

Guest cart session is not synced with Woocommerce cart session #285

Closed
hwsiew opened this issue May 20, 2020 · 6 comments
Closed

Guest cart session is not synced with Woocommerce cart session #285

hwsiew opened this issue May 20, 2020 · 6 comments

Comments

@hwsiew
Copy link
Contributor

hwsiew commented May 20, 2020

Describe the bug
If you add an item in cart as a guest using mutation, the Woocommerce cart session will remain empty. That means the cart sessions are different for mutation and Woocommerce.

To Reproduce
Steps to reproduce the behavior:

  1. Add an item to cart using addToCart mutation as a Guest in browser.
  2. Confirm the item is added in cart.
  3. Check the Woocommerce cart page

Expected behavior
Woocommerce cart page should have the same item added as addToCart mutation.

Additional context
latest wp-graphql and wp-graphql-woocommerce

@kidunot89
Copy link
Member

@hwsiew You need to use a WooCommerce Session Token for in order to use the cart. See this for a React/Apollo example 👉 #88

@hwsiew
Copy link
Contributor Author

hwsiew commented May 20, 2020

Hi @kidunot89,

I implemented the guide as in #88 with graphql JWT plugin. The cart is persistent in graphql as guest. So I will be able to add item to cart using mutation and get the cart items with query. But when I check the default Woocommerce cart page. The items added with addToCart mutation are not listed in default cart page.

@kidunot89
Copy link
Member

kidunot89 commented May 20, 2020

This is because they don't share the same session. WooGraphQL uses a custom session handling method.
WooCommerce core uses HTTP Cookies to store the session credentials unlike WooGraphQL which uses a JSON Web Token.

@hwsiew
Copy link
Contributor Author

hwsiew commented May 20, 2020

I see. Thank you for the explanation.

@guilhermejbranco
Copy link

@kidunot89 Is there a way to sync the guest cart to the user cart when the user logs in?

@sorensenjg
Copy link

sorensenjg commented Jun 3, 2021

@kidunot89 Im having the exact same issue. I would like to use the default checkout process instead of rebuilding all that logic on the react side. Is there an example or direction on how to sync sessions so the default checkout can be used? I think @jacobarriola has accomplished this, maybe he can chime in?

Its probably way more straight forward than I'm thinking... Im just stumped.

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

4 participants