Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's the purpose of this pull request?
This PR implements the "Reorder" button feature in the My Account order details page, allowing customers to quickly add all items from a previous order back to their cart with a single click. This improves the shopping experience by reducing friction when customers want to repurchase items they've bought before.
How it works?
The feature consists of:
Reorder Button Component (
MyAccountReorderButton): A dedicated button component displayed in the order details header that triggers the reorder action. The button is styled as outlined by default and filled on hover, and is hidden on mobile devices.Reorder Hook (
useReorder): A custom hook that handles the reorder logic:IStoreOffer[])validateCartGraphQL mutation to add items to the cartIntegration Points:
MyAccountOrderActionsdropdown menuuseReorderhookCart Synchronization: When the user already has items in their cart, the
validateCartmutation handles the synchronization by replacing all existing cart items with the reordered items from the order.Redirect to Checkout: After successfully adding items to the cart, users are automatically redirected to the checkout page using the
redirectToCheckoututility function, which handles both development and production environments.How to test it?
Starters Deploy Preview
References
validateCartmutation to add items to the cartMyAccountOrderDetails- Main order details pageMyAccountReorderButton- Reorder button componentMyAccountOrderActions- Order actions dropdownuseReorder- Reorder functionality hookredirectToCheckout- Checkout redirection utilityScreenshots
Checklist
PR Title and Commit Messages
feat,fix,chore,docs,style,refactor,ciandtestPR Description
breaking change,bug,contributing,performance,documentation..Dependencies
pnpm-lock.yamlfile when there were changes to the packagesDocumentation
@Mariana-Caetanoto review and update (Or submit a doc request)