Closed CervarlCG closed 1 year ago
@CervarlCG Are you overwriting your session by grabbing the new sessionToken
from the customer
field in the login response? If so, you should retrieve the updated token from the woocommerce-session
HTTP header in the response.
@kidunot89 when someone login both are saved in a cookie (session token and the new woocommerce-session http header) also in the next request the new woocommerce-session is send but the cart retrieved don't have the items added in guest mode (only users' persistent cart is retrieved)
@CervarlCG Not quite. The session provided to customer
field in login
mutation payload is a brand new session in the event you want to kill the old session. The woocommerce-session
response header is a modified version of the current sessionToken reassigned with the users newly logged user ID
@kidunot89 Sorry I think I did not explain well
In the login mutation i got the sessionToken
and the woocommerce-session
header, i stored they in a cookie and in every graphql request i send both as headers Authorization: bearer ...
woocommerce-session: ...
but my question is about the cart that the user had before loggin.
In a normal woocommerce installation when a user log in then the guest cart items are added to the user cart but in woocommerce graphql when i send the new Authorization
and woocommerce-session
the items aren't added to the cart and the user only got the persistent cart.
@CervarlCG WooGraphQL session is designed to behavior the same way, and replaces guest IDs with customer IDs upon login. You simply need to ignore the sessionToken
returned in the login
mutation. That one is designed to start a new session only. You should either woocommerce-session
from the response or execute a cart mutation/query with just the Authorization
header and retrieve the update sessionToken
And the sessionToken
and woocommerce-session
header in the GraphQL response are the same. You don't need them both. Just use whichever one works best with you application structure.
@CervarlCG Did you ever get this figured out?
@kidunot89 I updated the plugin some months ago and now it works fine
Describe the bug When I used the login mutation then i got the cart from the user but any product added in guest mode isn't saved after log in.
To Reproduce Steps to reproduce the behavior:
Expected behavior Items added as Guest would be added to the user cart
Desktop (please complete the following information):
Plugin Versions