Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Associate Anonymous Shopping Cart with User Account at Login/Registration #31

Open
LeHuth opened this issue Jun 22, 2023 · 0 comments
Open
Labels
Milestone

Comments

@LeHuth
Copy link
Owner

LeHuth commented Jun 22, 2023

Description

In our Frontend, currently, users can add items to their shopping cart even if they are not logged in. This shopping cart is stored in the user's cookies. However, when a user attempts to checkout, they are prompted to either log in or register an account.

This feature request involves modifying our login/registration processes to handle cases where the user has items in their anonymous cart. When the user logs in or registers, any items in their anonymous cart should be transferred to their backend shopping cart associated with their account. This will allow the checkout process to commence.

Expected Behavior

  • When an anonymous user (no account or not logged in) adds items to their cart, the items are stored in their cookies.
  • When this user then chooses to log in or register, the system should detect the presence of items in their cookie-stored cart.
  • Upon successful login or registration, if the user's account does not have an existing shopping cart, one should be created.
  • The items from the anonymous cart should be added to the user's backend shopping cart associated with their account.
  • If the user had items in their backend cart prior to this login/registration, the new items should be merged with the pre-existing ones.
  • Once the items have been transferred, the anonymous cart should be cleared from the cookies.
  • The user can now proceed with the checkout process.

Acceptance Criteria

  1. An anonymous user can add items to the shopping cart.
  2. If the user logs in or registers, the system identifies any items in the cookie-stored cart.
  3. If the user does not have a shopping cart in the backend, one is created.
  4. The items from the anonymous cart are added to the user's backend cart upon login/registration.
  5. Items previously existing in the backend cart are not lost or overwritten, but merged with the new items.
  6. (The cookie-stored cart is cleared after the transfer.)
  7. The user can successfully begin the checkout process with all the items in their backend cart.

Implementation Details

  • Update the login/register routes to check for the presence of a cookie-stored cart upon user login/registration.
  • If such a cart exists, iterate over its contents and add each item to the user's backend shopping cart.
  • If a backend shopping cart does not exist for the user, create one.
  • Handle cases where the same item might exist in both the anonymous and backend carts.
  • After successfully transferring the items, clear the cookie-stored cart.

Testing

  • Test the updated login/registration routes with and without an anonymous cart present.
  • Test cases where the same item exists in both carts to ensure items are merged correctly.
  • Confirm that after transferring items, the anonymous cart is cleared.
  • Test the creation of a new shopping cart if one does not exist for a user.

Additional Notes

This feature is important for ensuring a seamless shopping experience for our users. By preserving the contents of their cart across sessions and even before they have an account, we are minimizing friction in the purchasing process and potentially increasing sales. As such, the implementation of this feature should be given a high priority.

@LeHuth LeHuth added the Backend label Jun 22, 2023
@LeHuth LeHuth added this to the Cart Backend milestone Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant