-
Notifications
You must be signed in to change notification settings - Fork 277
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
Product options (unstable) #2482
base: main
Are you sure you want to change the base?
Conversation
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
|
||
// Get the variant for the current option value if exists, else use the first selectable variant | ||
// @ts-ignore | ||
const variant: ProductVariant = variants[targetKey] || value.firstSelectableVariant; |
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 think this should be:
const variant: ProductVariant = variants[targetKey] || value.firstSelectableVariant; | |
const variant: ProductVariant = variants[targetKey] || product.selectedOrFirstAvailableVariant; |
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.
It's not. product.options.optionValues.firstSelectableVariant
is the first available variant of this product variant. For example ...
We have product options as follows and the selected option is ['Red', 'Small'] and colors options is a combined listing.
[
['Red', 'Blue'],
['Small', 'Medium', 'Large]
]
Let's say I need to generate a link for Blue
option, however, ['Blue', 'Small'] is an option that doesn't exist and the first available variant is ['Blue', 'Medium'].
This is where we need the product.options.optionValues.firstSelectableVariant
which will return the variant for ['Blue', 'Medium']
Reworking product page to anticipate the new
unstable
API on product options and variantsWHY are these changes introduced?
2024-10 SFAPI will be introducing some changes to the product api.
WHAT is this pull request doing?
routes/product.$handle.tsx
- We should no longer need all variants (WIP)getProductOption
to correctly maps variants to various new api dataHOW to test your changes?
This PR has to run on the
unstable
SFAPI versionPost-merge steps
Checklist