Cart API¶

NXTBN Cart API¶

The NXTBN Add to Cart API is designed to support both authenticated and guest users. This mechanism ensures a seamless experience for users, whether logged in or not. Below is an overview of how the cart functionality works in each scenario:

Guest User Cart Management¶

  • Cart Storage in Session: When a user is not authenticated (i.e., a guest user), the cart items are temporarily stored in the session.

  • Placing an Order: Once the guest user places an order, the cart is cleared from the session, and no trace of the cart is retained.

Authenticated User Cart Management¶

  • Cart Storage in Database: For authenticated users, the cart items are stored in the database. This ensures that the cart is persistent across different sessions and devices.

  • Placing an Order: When an authenticated user places an order, their cart is cleared from the database, and no further action is required.

Cart Merging Mechanism¶

  • Guest Cart to Authenticated Cart Merge: If a guest user adds items to their cart and then later logs in or signs up, the following process occurs: - The cart items stored in the session are merged with the user’s database cart. - The session data is cleared, and the cart is now associated with the authenticated user’s account in the database.

This ensures a seamless transition from a guest cart to an authenticated cart without losing any items.

Benefits¶

  • Persistence: Authenticated users benefit from having their cart items stored in a persistent manner.

  • Seamless Transition: Guest users can add items to their cart and, upon logging in, have those items transferred to their account without any disruption.

This flexible design allows both guest and authenticated users to experience a smooth and uninterrupted cart experience.