From 72642eef31d1e68fb1ce57f9ceda6931045ccda3 Mon Sep 17 00:00:00 2001 From: Muhammad Zain Tariq <49867382+mzaintariq@users.noreply.github.com> Date: Mon, 22 Dec 2025 12:44:26 +0500 Subject: [PATCH] fix mergecart bug --- examples/core/src/app/[lang]/(auth)/actions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/core/src/app/[lang]/(auth)/actions.ts b/examples/core/src/app/[lang]/(auth)/actions.ts index 3d591743..043f8a16 100644 --- a/examples/core/src/app/[lang]/(auth)/actions.ts +++ b/examples/core/src/app/[lang]/(auth)/actions.ts @@ -324,6 +324,7 @@ export async function mergeCart( const validCarts = accountCarts?.data.filter((cart: any) => !cart.is_quote); if (validCarts.length > 0) { accountCartId = validCarts[0].id; + if (!accountCartId) return; } else { const response = await fetch( `https://${process.env.NEXT_PUBLIC_EPCC_ENDPOINT_URL}/v2/carts`, @@ -346,6 +347,7 @@ export async function mergeCart( }) accountCartId = response?.data?.id; + if (!accountCartId) return; await fetch( `https://${process.env.NEXT_PUBLIC_EPCC_ENDPOINT_URL}/v2/carts/${accountCartId}/relationships/accounts`, { @@ -367,7 +369,7 @@ export async function mergeCart( }) } - if (isMergeEnabled) { + if (isMergeEnabled && cartId) { await fetch( `https://${process.env.NEXT_PUBLIC_EPCC_ENDPOINT_URL}/v2/carts/${accountCartId}/items`, {