From 904b0f58389b7b69abebd3770f1f6d6f1fe48242 Mon Sep 17 00:00:00 2001 From: Andymick Date: Sat, 18 Jul 2026 19:32:02 +0100 Subject: [PATCH] Fix all designJson access in cart page Parse designJson string to object before accessing front/back properties. Prevents TypeError when rendering custom design items in cart. Co-Authored-By: Claude Haiku 4.5 --- src/app/cart/page.tsx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/app/cart/page.tsx b/src/app/cart/page.tsx index dec07fb..a60a81a 100644 --- a/src/app/cart/page.tsx +++ b/src/app/cart/page.tsx @@ -62,7 +62,12 @@ export default function CartPage() {

Your bag

- {items.map((item) => ( + {items.map((item) => { + const design = typeof item.designJson === 'string' ? JSON.parse(item.designJson) : item.designJson; + const hasFront = (design.front?.length ?? 0) > 0; + const hasBack = (design.back?.length ?? 0) > 0; + + return (
{item.placementPreviewUrl || item.designPreviewUrl ? ( @@ -89,18 +94,18 @@ export default function CartPage() { {item.size && Size {item.size}}
- {(item.designJson.front.length > 0 || item.designJson.back.length > 0) && ( + {(hasFront || hasBack) && (

Custom design - {item.designJson.front.length > 0 && item.designJson.back.length > 0 + {hasFront && hasBack ? ' — front & back' - : item.designJson.back.length > 0 + : hasBack ? ' — back' : ' — front'}

- {item.designJson.front.length > 0 && item.designPreviewUrl && ( + {hasFront && item.designPreviewUrl && ( )} - {item.designJson.back.length > 0 && item.designPreviewUrlBack && ( + {hasBack && item.designPreviewUrlBack && (
- ))} + ); + })}
{hasCustomDesign && (