-
Notifications
You must be signed in to change notification settings - Fork 283
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
Support 2k variant, combined listing usage with getProductOptions #2659
Conversation
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
This comment has been minimized.
This comment has been minimized.
Doubled checked on the newly generated types - the SitemapQuery is suppose to go away since it got migrated to the Hydrogen package. We just forgot to update the generated types in the examples. |
product: RecursivePartial<Product>, | ||
): ProductVariant[] { | ||
// Checks for valid product input | ||
const checkedProduct = checkProductParam(product); |
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.
Why does sometimes checkProductParm
"checkAll" vs other times not? Looks like it has to do with whether it checks for PRODUCT_INPUTS_EXTRA
existing on the return product object. But why would we want to check that in one spot but not the other?
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 want to reuse the checkProductParam
with the getAdjacentAndFirstAvailableVariants
.
The purpose of getAdjacentAndFirstAvailableVariants
is to return an unique list of variants found in options.optionValues.firstAvailableVariant
, adjacentVariants
, and selectedOrFirstAvailableVariant
.
The getAdjacentAndFirstAvailableVariants
doesn't require other fields to be present like encodedVariantExistence
, and encodedVariantAvailability
.
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.
In testing it, I noticed going from the collection page to a product, I often landed directly on an unavailable variant. This confused me because we have all the logic for firstAvailableVariant
. It turns out we hard-code adding the first selected option in the template: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/lib/variants.ts#L45
I suggest we update that code to remove the selected option query parameter. That will make it automatically find and select the first available variant.
Good catch - I thought I found all of them |
@blittle I have addressed the following:
|
/snapit |
🫰✨ Thanks @blittle! Your snapshots have been published to npm. Test the snapshots by updating your "@shopify/cli-hydrogen": "0.0.0-snapshot-20241210144810",
"@shopify/hydrogen": "0.0.0-snapshot-20241210144810"
|
.changeset/three-cows-shave.md
Outdated
'@shopify/hydrogen': patch | ||
--- | ||
|
||
Introduce `getProductOptions`, `getAdjacentAndFirstAvailableVariants`, and `mapSelectedProductOptionToObject` to support combined listing products and products with 2000 variants limit. |
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.
Also needs the new useSelectedOptionInUrlParam
hook now
/snapit |
🫰✨ Thanks @wizardlyhel! Your snapshots have been published to npm. Test the snapshots by updating your "@shopify/cli-hydrogen": "0.0.0-snapshot-20241210171242",
"@shopify/hydrogen": "0.0.0-snapshot-20241210171242"
|
WHY are these changes introduced?
Uses the new product fields to build the product form in support of 2k variant and combined listing:
Provides:
getProductOptions
function that will return product options along with the states of this current variantWHAT is this pull request doing?
HOW to test your changes?
Post-merge steps
Checklist