You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue
When a guest user logs in to user account while there are products in the cart the cart content is copied over to a new session in the woocommerce_sessions table where the key is the logged in customer_id. The guest session cart stays in the table also. Thus there are now two instances of the same cart. This leads to problems when the store is selling unique single quantity items and has availability checks in place to prevent multiple customers from purchasing the same item either with a custom code or by using something like Cart Stock Reducer plugin. https://wordpress.org/support/topic/product-in-cart-not-available-after-logging-in/
Solution
I propose deleting the guest session after user logs in. The cart content that the user had in the cart before logging in should still carry over to the logged in session and be merger with possible persistent cart content. I was already able to built a working solution by customizing the class-wc-session-handler.php file where the guest customer id is carried over to the function where the cart content is copied and after the copying is done then the redundant guest sessions is deleted with this key. I'll submit a pull request.
Alternatives
Alternative solution might be to update the guest user session with the logged in user details instead of copying the cart.
The text was updated successfully, but these errors were encountered:
The issue
When a guest user logs in to user account while there are products in the cart the cart content is copied over to a new session in the woocommerce_sessions table where the key is the logged in customer_id. The guest session cart stays in the table also. Thus there are now two instances of the same cart. This leads to problems when the store is selling unique single quantity items and has availability checks in place to prevent multiple customers from purchasing the same item either with a custom code or by using something like Cart Stock Reducer plugin. https://wordpress.org/support/topic/product-in-cart-not-available-after-logging-in/
Solution
I propose deleting the guest session after user logs in. The cart content that the user had in the cart before logging in should still carry over to the logged in session and be merger with possible persistent cart content. I was already able to built a working solution by customizing the class-wc-session-handler.php file where the guest customer id is carried over to the function where the cart content is copied and after the copying is done then the redundant guest sessions is deleted with this key. I'll submit a pull request.
Alternatives
Alternative solution might be to update the guest user session with the logged in user details instead of copying the cart.
The text was updated successfully, but these errors were encountered: