I’m running into a quirk setting up the B2B features in our Hydrogen store. I’ve followed the B2B cookbook and everything is working great from the Hydrogen side, however after sending to checkout the buyerIdentity on the cart is being overwritten with whatever the state of the checkout UI is.
For full context, we have:
- Hydrogen storefront at example.com
- Checkout at checkout.example.com
- Customer Accounts at account.example.com
- A customer with 2 company locations (A and B)
- Separate product catalogs for locations A and B
This is the flow that gets into the situation I’m describing:
- When selecting location A in Hydrogen, adding products to cart, and then navigating to checkout, I’m initially redirected to a location selector under account.example.com
- Select location A in this selector, and it redirects back to checkout (all good)
- Using the link to change locations in the checkout, I switch to location B. Once redirected back to checkout I get presented with a message about stock problems with the items in the cart (all good, expected as B does not have access to the same product catalog)
- I then go back out to Hydrogen and select location A, rebuild the cart
- Navigate to checkout and am immediately given the stock problems message again, because checkout is still set to location B
My initial thought was that I wasn’t properly setting the buyerIdentity on the cart before navigating to checkout, but I confirmed with the GraphQL API after step 4 that the buyerIdentity on the cart is correctly set to location A. After loading into checkout in step 5 and checking the cart with GraphQL again, it now shows buyerIdentity changed to location B.
I’m sure I’m probably just missing something, but any help getting me in the right direction would be much appreciated!