From f72e93494327347419a96ec6b659bb7aecb5e1e7 Mon Sep 17 00:00:00 2001 From: Andymick Date: Sat, 18 Jul 2026 19:29:45 +0100 Subject: [PATCH] Fix cart page error when reading designJson Handle designJson as either string or object, parse if needed. Prevents TypeError when accessing front/back properties. Co-Authored-By: Claude Haiku 4.5 --- src/app/cart/page.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/cart/page.tsx b/src/app/cart/page.tsx index a18b321..dec07fb 100644 --- a/src/app/cart/page.tsx +++ b/src/app/cart/page.tsx @@ -12,7 +12,14 @@ export default function CartPage() { const removeItem = useCart((s) => s.removeItem); const setQuantity = useCart((s) => s.setQuantity); const total = useCart((s) => s.total()); - const hasCustomDesign = items.some((item) => item.designJson.front.length > 0 || item.designJson.back.length > 0); + const hasCustomDesign = items.some((item) => { + try { + const design = typeof item.designJson === 'string' ? JSON.parse(item.designJson) : item.designJson; + return (design.front?.length ?? 0) > 0 || (design.back?.length ?? 0) > 0; + } catch { + return false; + } + }); useEffect(() => setMounted(true), []);