Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cart Id / Cookie is not reset on checkout completed #2524

Open
gmilon opened this issue Sep 12, 2024 · 8 comments
Open

Cart Id / Cookie is not reset on checkout completed #2524

gmilon opened this issue Sep 12, 2024 · 8 comments
Labels

Comments

@gmilon
Copy link

gmilon commented Sep 12, 2024

What is the location of your example repository?

No response

Which package or tool is having this issue?

Hydrogen

What version of that package or tool are you using?

2024.7.4

What version of Remix are you using?

2.10.1

Steps to Reproduce

Note: This happens to some users after placing multiple orders.

  • add product to cart
  • go to checkout ext and place an order
  • go back to the main hydrogen store

Anyone knows how hydrogen handle the cart reset event post checkout ?
Maybe we missed something in the flow.

is there any cart property we can check on storefront to reset the cart manually?
We cannot find anything related to the checkout / order in the Cart object definition.

Expected Behavior

Cart is empty and user can add new product and place a new order.

Actual Behavior

Cart still have the previous items and the checkout link redirect the user to the order thank you page.

@wizardlyhel
Copy link
Contributor

We're looking into this

@wizardlyhel
Copy link
Contributor

@gmilon If you have cart id examples that is showing this behaviour, please share here. It would help us greatly on investigation

@sbaleno
Copy link

sbaleno commented Sep 18, 2024

I am seeing this as well with a b2b setup. Using unstableB2b: true in app load context. I can't seem to get the cart back to a good place after checkout.

@wizardlyhel
Copy link
Contributor

@sbaleno If you have cart ids that is showing this behaviour, please share

@wizardlyhel
Copy link
Contributor

wizardlyhel commented Sep 18, 2024

@gmilon @sbaleno - If you have order id that show this behaviour, that works too. But this does mean you need to share the store url as well.

You can DM on twitter @wizardlyhel if sharing the url here isn't an option or DM me in the Shopify partner slack channel if you already have access.

@mhxim
Copy link

mhxim commented Oct 9, 2024

Hey @wizardlyhel, I'm encountering a similar issue while trying out Hydrogen.

In the Dawn standard store setup the cart cookie is automatically removed after checkout. However this isn't happening for my custom Hydrogen storefront both on the deployed and localhost version. The same cart cookie is still present (with the same value) and causing issues. The issues get resolved after I manually remove the cart cookie.

I've also noticed that the cart from useOptimisticCart appears to be "reset" at the storefront after checkout (new ids, no buyeridentity) but the same cookie value for the cart remains. This makes it hard for me to identify if the current cart cookie should be removed (which would fix it for now I guess).

Best,
Maxim

(using hydrogen version 2024.7.9)

@wizardlyhel
Copy link
Contributor

@mhxim It's expected that after checkout, if the buyer returns to the site, the cart cookie remains with the old cart cookie. This is because that the next cart mutation should give you a new cart id.

It's why in cart.tsx, we need to set the cart cookie with the result cart id after each cart mutation. https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/routes/cart.tsx#L75-L77

@lorenzo-del-rosario
Copy link
Contributor

We are facing the same issue with 2 different scenarios:

  • Some user have some items in their cart and when navigating to checkout an old checkout session (with different items) is displayed.
  • Other users have some items in their cart and when navigating to the checkout page the Thank You page is displayed.

Using "@shopify/hydrogen": "2024.7.1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants