-
Notifications
You must be signed in to change notification settings - Fork 273
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
Adding an example for B2B #1886
Conversation
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
7d5477f
to
ebefc4f
Compare
new Date( | ||
new Date().getTime() + (expires_in! - 120) * 1000, | ||
).getTime() + '', | ||
new Date(new Date().getTime() + (expires_in - 120) * 1000).getTime() + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the ! in this line.
452b690
to
b026930
Compare
This comment has been minimized.
This comment has been minimized.
2739668
to
d1a15c1
Compare
a88b87c
to
994ba78
Compare
cdce061
to
301d0e0
Compare
301d0e0
to
cdce061
Compare
I also did some clean up on the |
53e99a1
to
eade5ee
Compare
working queries contextualized queries quantity and volume prices added header selector login redirect handle single location buyers convert location selector to form convert location dropdown to form update input type
move token exchange and add get set buyer move set buyer into customerAccount remove buyer expire remove locations and use cart instead automatically get buyeridentity from customerAccount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 👏 👏
Overall really well done and it looks great and works well!
I made a bunch of suggestions on the PR but the really important ones that's must fix are:
- missing
maximum
rule from Cart.tsx - 🐛 quantity increment rule in Cart.tsx
- 🐛 updating Cart after logout
- do not cache storefront query with customer account token
- add a changeset for @shopify/hydrogen unstable features
Addressed the comments and got approval from @michenly
Adding an example for B2B, along with an update to the customer account client to support a storefront customer access token via the storefrontCustomerAccessTokenCreate mutation.
WHY are these changes introduced?
Resolves #1677
Hydrogen utilities method for b2b merchant to use.
here is the flow for a typical B2B Hydrogen store
customerAccountAccessToken
, and exchange it forstorefrontCustomerAccountAccessToken
immediately after authorizeWHAT is this pull request doing?
Encapsulating common tasks into hydrogen utilities
storefront
client, ifb2b
option is true, a query variable will get automatically created by usingbuyer = customerAccount.UNSTABLE_getBuyer()
customerAccount
, at the end ofauthorize()
, do a token exchange and saved to session.customerAccount
, exposeUNSTABLE_setBuyer
andUNSTABLE_getBuyer
to get and set Buyer on the session. the getter will do a login + expire check, if customerAccessToken is expired and need refresh, the storefrontCustomerAccessToken will automatically follow as wellcreateCartHandler
, when we create the cart, the mutation will be run with buyerIdentity coming fromcustomerAccount.UNSTABLE_getBuyer()
directlyHOW to test your changes?
Post-merge steps
Checklist