-
Notifications
You must be signed in to change notification settings - Fork 354
[2025-07] Add cartGiftCardCodesRemove mutation support #3128
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: 2025-07-sfapi-caapi-update
Are you sure you want to change the base?
[2025-07] Add cartGiftCardCodesRemove mutation support #3128
Conversation
- Add new cartGiftCardCodesRemove mutation handler for removing specific gift cards by ID - Integrate removeGiftCardCodes method into cart handler - Add GiftCardCodesRemove action to CartForm - Update cart fragments to include appliedGiftCards.id field - Implement gift card removal UI in skeleton template - Maintain existing additive behavior for adding/updating gift cards - Add tests for new mutation handler
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
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.
Pull Request Overview
This PR adds support for the new cartGiftCardCodesRemove
mutation introduced in Storefront API 2025-07, addressing the inability to remove individual gift cards when multiple are applied to a cart.
- Added
cartGiftCardCodesRemoveDefault
mutation handler and corresponding cart method - Added
GiftCardCodesRemove
action to CartForm for form-based gift card removal - Updated cart fragments to include gift card
id
field required for removal operations
Reviewed Changes
Copilot reviewed 13 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
templates/skeleton/app/routes/cart.tsx | Added handler for GiftCardCodesRemove action |
templates/skeleton/app/lib/fragments.ts | Added id field to appliedGiftCards fragment |
templates/skeleton/app/components/CartSummary.tsx | Updated UI with individual remove buttons per gift card |
packages/hydrogen/src/index.ts | Added export for cartGiftCardCodesRemoveDefault |
packages/hydrogen/src/cart/queries/cartGiftCardCodesRemoveDefault.ts | New mutation handler implementation |
packages/hydrogen/src/cart/queries/cartGiftCardCodesRemoveDefault.test.ts | Added test coverage for new mutation |
packages/hydrogen/src/cart/queries/cartGiftCardCodesRemoveDefault.example.ts | TypeScript usage example |
packages/hydrogen/src/cart/queries/cartGiftCardCodesRemoveDefault.example.js | JavaScript usage example |
packages/hydrogen/src/cart/queries/cartGiftCardCodesRemoveDefault.doc.ts | Documentation configuration |
packages/hydrogen/src/cart/queries/cartGetDefault.ts | Added appliedGiftCards to default cart fragment |
packages/hydrogen/src/cart/createCartHandler.ts | Added removeGiftCardCodes method to HydrogenCart |
packages/hydrogen/src/cart/CartForm.tsx | Added GiftCardCodesRemove action type and props |
.changeset/gift-card-removal.md | Added changeset documentation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
7bf52b5
to
8c4eed6
Compare
WHY are these changes introduced?
Addresses https://github.com/Shopify/hydrogen-internal/issues/231
The Storefront API 2025-07 release deprecated
cartGiftCardCodesUpdate
in favor of separatecartGiftCardCodesAdd
andcartGiftCardCodesRemove
mutations. This change addresses a critical UX issue where users couldn't remove individual gift cards when multiple were applied, since the API only returns the last 4 digits of gift card codes for security reasons.WHAT is this pull request doing?
This PR adds support for the new
cartGiftCardCodesRemove
mutation to enable removing specific gift cards by their IDs.Key Changes
removeGiftCardCodes
methodGiftCardCodesRemove
actionid
field toappliedGiftCards
Technical Details
cartGiftCardCodesRemoveDefault
appliedGiftCardIds
parameter (notgiftCardCodes
)as any
usageHOW to test your changes?
Start the skeleton dev server:
cd templates/skeleton npm run dev
Add a product to the cart
Apply multiple gift cards
Verify:
Checklist