From f1537402b59c7382d9834c93cca0a19223609a80 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 18 Jun 2026 11:08:17 -0400 Subject: [PATCH] Disable sold-out variants in picker; default to first in-stock option Sold-out variant buttons now show "Sold Out" and can't be selected. The picker also defaults to the first in-stock variation instead of always starting on variations[0], which could be out of stock. Co-Authored-By: Claude Sonnet 4.6 --- estore/src/components/ColorPicker.tsx | 42 +++++++++++++++++---------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/estore/src/components/ColorPicker.tsx b/estore/src/components/ColorPicker.tsx index 7c7dc4f..8047a9d 100644 --- a/estore/src/components/ColorPicker.tsx +++ b/estore/src/components/ColorPicker.tsx @@ -50,7 +50,9 @@ export default function ColorPicker({ product, maxColors, onClose, editingEntry const [notes, setNotes] = useState(editingEntry?.notes ?? '') const [activeImg, setActiveImg] = useState(0) const [userVariationId, setUserVariationId] = useState( - () => editingEntry?.selectedVariationId ?? product.variations[0]?.id + () => editingEntry?.selectedVariationId + ?? product.variations.find((v) => v.inventory === null || v.inventory > 0)?.id + ?? product.variations[0]?.id ) // Vinyl state @@ -285,21 +287,29 @@ export default function ColorPicker({ product, maxColors, onClose, editingEntry
- {selectableVariations.map((v) => ( - - ))} + {selectableVariations.map((v) => { + const varSoldOut = v.inventory !== null && v.inventory <= 0 + return ( + + ) + })}
)}