hydrogen icon indicating copy to clipboard operation
hydrogen copied to clipboard

Hydrogen React - Customer errors after placing order

Open bradleyDouglas opened this issue 2 years ago • 1 comments

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?

2023.10.0

What version of Remix are you using?

N/A

Steps to Reproduce

I posted this in the Discord channel, but hoping to maybe get more info/clarity here...

I'm currently developing a custom storefront using the Headless channel and Next JS on the front end. I have everything working as I would hope (login, log out, add to cart, go to checkout, etc). However, after placing a test order (this is a dev store with the dummy checkout) I have run into two issues I'm hoping somebody can help me with:

  1. After placing the test order using "1" as my card number to indicate a successful order, I can see the order info on the timeline of my user account in the Shopify Admin, but the order is not in the "Last order placed" section. I have attached an image.

  2. After placing the order, something happened to my customer info and now my app doesn't recognize/return the customer. For instance, I logged out and tried logging back in. Usually, after a successful attempt (token returned), the Fetch happens, and once that returns the customer data, the user is set in state and the UI now shows the customer account page. But, for some reason, the fetch is returning null. I have confirmed that the login is providing an Access Token.

My hunch is that after placing the order, something happened to my customer data. I've attached a screenshot of the console logs after logging in. You can first see the token that is returned, then the null that is returned from my fetch user call. As you can also see (not see) there aren't any errors being returned.

Happy to provide any more info or code, but first wanted to describe the issues in hopes that somebody has experienced this as well and can tell me where I'm messing up. FWIW, all the customers are being created with classic accounts. Screenshot 2023-12-11 at 10 10 16 AM console-screenshot

Expected Behavior

My expected behavior would be that the order is being associated with the customer within Shopify admin AND the customer can log in as usual after an order (and see their order history).

Actual Behavior

The order isn't associated with the customer's order history and I can't log in in after placing an order.

bradleyDouglas avatar Dec 12 '23 15:12 bradleyDouglas

HI bradleyDouglas I am sorry we didnt get back to you sooner.

The scenario you described reminds me of customer activation flow. That while the customer might exist, there are functionalities disabled before the customer activate their account through email. I am not sure if this is the case, would need more information for sure.

I do also want to let you know that there is a new Customer Account API available now - this API encourage a passwordless login experience where your app will no longer need to deal with customer password. The latest version of Hydrogen and demo-store are both using this new API if you want examples.

michenly avatar Feb 06 '24 19:02 michenly

I think we can close this issue @michenly

jamalsoueidan avatar Apr 22 '24 19:04 jamalsoueidan