-
Notifications
You must be signed in to change notification settings - Fork 378
feat: add support for nested cart lines #3398
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
base: graphite-base/3398
Are you sure you want to change the base?
feat: add support for nested cart lines #3398
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
828daa8 to
aa8ea9b
Compare
kdaviduik
left a comment
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 didn't have enough time for a full pass, I will continue tomorrow :)
| \ No newline at end of file | ||
| ~~~ | ||
|
|
||
| ### Step 2: Let customers change variants directly in the cart |
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.
are all these deletions supposed to be there? also i'm surprised this recipe doesn't use patch files
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.
most of the files are regenerated cookbooks, i did not write them myself!
i wonder if we can futurely gitignore those and generate them via CI only for the release step of the CLI (like building a package, the /dist of that package is often only in npm, not committed)
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.
The cookbook stuff is very borked, but tomorrow we can pair to fix that if you want to learn how :) I'd recommend reverting all of the changes to the cookbook folder as it'll be easier to start fresh.
the regenerate command sounds like it would be what we want to use here, but it actually is for a very different use case. so using it here deleted a lot of the actual content of the recipes, since when you regenerated them the recipe wasn't already applied to the skeleton. the best thing to do (after reverting all of the cookbook changes) would be to manually (probably with AI assistance :P) update the patch files of the specific recipes that are failng validation, so that the patch files will now work as diffs against the new version of the skeleton with all of your changes. But since we're doing so many separate changes to the skeleton as part of this work, I think we're better off just ignoring "validate recipes" CI check and fixing it at the end once all PRs are merged into the stack. Discussion here
Imo the cookbook commands are very misleading and confusing, and there's no command to do what we need for the most common use case. I want to fix this in the future. I have a doc here with a bit more information and some very WIP/draft ideas to fix these
| // Useful when you know the product variant but not the cart line ID | ||
| <AddToCartButton | ||
| variantId="gid://shopify/ProductVariant/warranty-123" | ||
| parent={{merchandiseId: 'gid://shopify/ProductVariant/laptop-456'}} |
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.
note for other reviewers: this is using the actual type from the SF API, so the parent line item ID is also accepted here. either one works
aa8ea9b to
d0bba38
Compare
37ee345 to
cd65345
Compare
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 reverted everything but these two files were not formatted with eslint before, so some white spaces were fixed
|
yeah will revert! it’s really hard to maintain the patches though, it’s not the most ergonomic of formats :( your proposal is a good step to automate this, but i think there is no easy way to do these patches automatically |

WHY are these changes introduced?
SFAPI 2025-10 introduces
parentRelationshipto line items. It means we can now access and render line items with hierarchy.This PR adds support for displaying child line items in the cart, such as warranties or gift wrapping options that are associated with a parent product.
WHAT is this pull request doing?
CartLineItemcomponent to display child components nested under their parent line itemsCartLineChildcomponent to render child line items with appropriate stylinglineComponentsandparentRelationshipdataHOW to test your changes?
Because we don’t offer a way to add a child product in this (there are infinity ways of doing it and it’s down to the store manager to do it) you will have to make a few code changes.
npm run build --filter=skeleton) and run the skeleton dev servercd templates/skeleton && npm run devhttp://localhost:3000/graphiqland call this:ProductForm.tsxline 123, replacingYOUR_WARRANTY_VARIANT_IDwith a variant id you got form step 2.Checklist