Skip to content

Guest cart lost when logging in #12

@John-Ad

Description

@John-Ad

Problem

If a user is not logged in and they add items to their cart, when they proceed to checkout, they are prompted to log in. Once logged in, the cart they had when they were not logged in is lost.

Expected outcome

The guest cart should be merged with the customer cart. Eg, if orderOptions.mergeStrategy in vendure-config.ts is UseGuestStrategy, the customer cart should be replaced with the guest cart.

Possible fix

In /apps/storefront/src/app/sign-in/actions.ts, the mutate call in loginAction does not make use of the guest auth token. Adding the token allows for the carts to be merged:

const result = await mutate(LoginMutation, {
        username,
        password,
    }, { useAuthToken: true });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions