diff --git a/src/app/[locale]/checkout/page.tsx b/src/app/[locale]/checkout/page.tsx index 05a2c12..cfcac3d 100644 --- a/src/app/[locale]/checkout/page.tsx +++ b/src/app/[locale]/checkout/page.tsx @@ -13,6 +13,7 @@ import { saleorClient } from "@/lib/saleor/client"; import { useAnalytics } from "@/lib/analytics"; import { CHECKOUT_SHIPPING_ADDRESS_UPDATE, + ORDER_CONFIRM, } from "@/lib/saleor/mutations/Checkout"; import { PaymentSection } from "./components/PaymentSection"; import { DEFAULT_PAYMENT_METHOD } from "@/lib/config/paymentMethods"; @@ -306,6 +307,21 @@ export default function CheckoutPage() { setOrderNumber(result.order.number); setOrderComplete(true); + // Auto-confirm the order + try { + console.log("Auto-confirming order:", result.order.id); + await saleorClient.mutate({ + mutation: ORDER_CONFIRM, + variables: { + orderId: result.order.id, + }, + }); + console.log("Order confirmed successfully"); + } catch (confirmError) { + console.error("Failed to auto-confirm order:", confirmError); + // Don't fail the checkout if confirmation fails + } + // Clear the checkout/cart from the store clearCheckout(); diff --git a/src/lib/saleor/mutations/Checkout.ts b/src/lib/saleor/mutations/Checkout.ts index 169f705..9fbedd2 100644 --- a/src/lib/saleor/mutations/Checkout.ts +++ b/src/lib/saleor/mutations/Checkout.ts @@ -224,3 +224,19 @@ export const TRANSACTION_CREATE = gql` } } `; + +export const ORDER_CONFIRM = gql` + mutation OrderConfirm($orderId: ID!) { + orderConfirm(id: $orderId) { + order { + id + number + status + } + errors { + field + message + } + } + } +`;