Skip to content

Add three one-click reorder options to order history - #1282

Open
claire-carew wants to merge 1 commit into
saleor:mainfrom
claire-carew:feature/buy-again-order-options
Open

claire-carew wants to merge 1 commit into
saleor:mainfrom
claire-carew:feature/buy-again-order-options

Conversation

@claire-carew

Copy link
Copy Markdown

What this adds

A "Buy again" action on the account order-history page that adds a past order's still-available lines to the current cart. Three presentations are included so they can be compared, switchable with ?view=:

  • Quick repeat (?view=quick, default): one button per order that re-adds every available line at the original quantity.
  • Receipt (?view=receipt): the order expands into its line items, with a single "Add all to cart" action.
  • Choose items (?view=choose): per-line checkboxes and quantities, then add only the selected lines.

Lines whose variant is deleted, unpublished in the channel, or out of stock are skipped, and the UI reports what was skipped.

How it works

  • src/graphql/extensions/BuyAgain.graphql: BuyAgainOrder fragment (spread into CurrentUserOrdersPaginated) and a BuyAgainAdd checkout-lines mutation, registered as a session mutate operation in src/config/data-extensions.ts.
  • src/lib/custom/buy-again.ts: pure logic that turns order lines into checkout lines, filtering unavailable variants and merging duplicates.
  • src/app/buy-again/actions.ts: server action that resolves or creates the cart and calls the mutation through @/lib/saleor.
  • src/ui/components/account/buy-again.tsx: client component for the three views; order-row.tsx gains a grouped prop; the orders page renders the view switcher.
  • messages/en.json strings under account.buyAgain; data-layer.lock.md regenerated.

Validation

  • pnpm run verify passed: 129 test files, 795 tests, lint 0 errors. New unit tests cover the line-mapping logic and the server action.
  • Browser run against the local stack: the cart went 3 → 6 → 7 items across Quick repeat and Choose items, ending with 4 tees and 3 shirts and no unavailable tote. No order or payment was made.
  • pnpm run build was not run.

Notes for review

  • All three approaches are included so the team can pick one; my recommendation is to keep Quick repeat and drop the other two before merge.
  • The branch is based on an older commit of main and has not been rebased.

~ written by ⠕ Replit

@claire-carew
claire-carew requested review from a team, mirekm and peelar as code owners November 30, 2026 17:49
@vercel

vercel Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

@claire-carew is attempting to deploy a commit to the Saleor Commerce Team on Vercel.

A member of the Team first needs to authorize it.

@claire-carew

Copy link
Copy Markdown
Author

make it red instead of blue

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant