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:
addToCart mutation as a Guest in browser.Expected behavior
Woocommerce cart page should have the same item added as addToCart mutation.
Additional context
latest wp-graphql and wp-graphql-woocommerce
@hwsiew You need to use a WooCommerce Session Token for in order to use the cart. See this for a React/Apollo example 馃憠 https://github.com/wp-graphql/wp-graphql-woocommerce/pull/88
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.
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.
I see. Thank you for the explanation.
@kidunot89 Is there a way to sync the guest cart to the user cart when the user logs in?
@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.
Most helpful comment
@kidunot89 Is there a way to sync the guest cart to the user cart when the user logs in?