Skip to content

Fix duplicate order creation during checkout submission - #909

Open
AanyaJain0811 wants to merge 1 commit into
adithyan-css:mainfrom
AanyaJain0811:fix/prevent-duplicate-order-submission
Open

Fix duplicate order creation during checkout submission#909
AanyaJain0811 wants to merge 1 commit into
adithyan-css:mainfrom
AanyaJain0811:fix/prevent-duplicate-order-submission

Conversation

@AanyaJain0811

Copy link
Copy Markdown

Summary

Rapid or repeated clicks on "Place Order" during checkout could fire multiple POST /orders requests before the first one resolved, since nothing blocked re-entry into placeOrder() while it was awaiting the API call. This created duplicate orders and triggered sendWhatsAppFinal() (and its WhatsApp window) more than once per checkout.

Changes Made

  • Added a module-level isSubmitting flag, checked at the top of placeOrder(). Any call made while a request is already in flight returns immediately, so this is the actual fix — not just a UI nicety.
  • Disabled the "Place Order" button and swapped its label to "Processing..." for the duration of the request, giving the user clear feedback that their click registered.
  • Wrapped the request in try/catch/finally, so isSubmitting and the button's disabled state/label always reset — on success, on a handled failure (data.success === false), and on a thrown/network error alike.

Impact

  • Eliminates duplicate order creation from double-clicks or repeated taps on slow connections.
  • Prevents multiple WhatsApp windows from opening per checkout.
  • No behavior change for the normal single-click flow; the button simply locks for the brief duration of the request and unlocks automatically regardless of outcome.

Fixes #908

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

@AanyaJain0811 is attempting to deploy a commit to the adithyansubramani1-1657's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Prevent duplicate order creation during checkout submission

1 participant