- );
- }
-
- return (
-
- );
-}
diff --git a/src/components/customer/checkout-payment.tsx b/src/components/customer/checkout-payment.tsx
index 5d4f822..f4837d0 100644
--- a/src/components/customer/checkout-payment.tsx
+++ b/src/components/customer/checkout-payment.tsx
@@ -37,14 +37,16 @@ export function CheckoutPayment({
return;
}
startTransition(async () => {
- // submitCheckout processes the whole cart at once (splits into per-store orders
- // server-side), not just this store — see PageProps note on the confirm page.
const result = await submitCheckout({
address_uuid: addressUuid,
delivery_type: "express",
scheduled_at: null,
payment_method: method,
notes: "",
+ // Scopes this checkout to just this store's cart group — without this,
+ // the backend checked out the entire cart regardless of which store's
+ // "پرداخت" button was pressed.
+ store_uuids: [group.store.uuid],
});
if (result.ok) {
router.push(`/order-groups/${result.data.uuid}`);
diff --git a/src/lib/api/checkout.ts b/src/lib/api/checkout.ts
index dc10ce5..1697d6d 100644
--- a/src/lib/api/checkout.ts
+++ b/src/lib/api/checkout.ts
@@ -1,5 +1,6 @@
"use server";
+import { revalidatePath } from "next/cache";
import { winofyFetch } from "./winofy";
import { callApi, type ActionResult } from "./result";
import type { DeliveryType, OrderGroup, PaymentMethod } from "@/types/api";
@@ -10,8 +11,21 @@ export interface CheckoutInput {
scheduled_at: string | null;
payment_method: PaymentMethod;
notes: string;
+ /**
+ * Which store-cart-groups to check out, by store uuid. Required (not optional) —
+ * every caller must be explicit about scope now; there's no more implicit
+ * "everything in the cart" default. This is what fixes the bug where paying for
+ * one store's order submitted every store's order: previously nothing on this
+ * request identified which store(s) were intended, so the backend checked out
+ * the whole cart every time.
+ */
+ store_uuids: string[];
}
export async function submitCheckout(input: CheckoutInput): Promise> {
- return callApi(() => winofyFetch("/v1/checkout/", { method: "POST", body: input }));
+ const result = await callApi(() => winofyFetch("/v1/checkout/", { method: "POST", body: input }));
+ // Only the scoped store(s)' items are removed server-side now — the cart page
+ // (and the sticky-cart-bar badge) needs a fresh fetch to stop showing them.
+ if (result.ok) revalidatePath("/cart");
+ return result;
}