Skip to main content

Advanced Flows: Cart Lifecycle

The Archibald Cart module handles complex lifecycle transitions, most notably the transition from an anonymous guest cart to a registered user cart.

Anonymous to Registered Merge Flow

When a user adds items to their cart as a guest and subsequently logs in, the framework manages the merging of these carts to ensure no data is lost.

Key Considerations

  • Identifier Transition: The hook automatically switches from using the guid (anonymous) to the code (registered) identifier after a successful merge.
  • Event Propagation: The CartClient will emit a 'cart' event with the merged state, allowing UI components to refresh automatically.
  • Persistence: The useCartId hook updates the underlying cookie/storage to ensure the registered cart persists across page reloads.