Skip to content

Commit 65c04a9

Browse files
authored
Merge branch 'main' into fix/cart-shipping-options
2 parents edadec4 + 4939435 commit 65c04a9

File tree

1 file changed

+13
-3
lines changed
  • src/modules/products/components/product-actions

1 file changed

+13
-3
lines changed

src/modules/products/components/product-actions/index.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,23 @@ export default function ProductActions({
9797

9898
// check if the selected variant is in stock
9999
const inStock = useMemo(() => {
100-
if (variant && !variant.inventory_quantity) {
101-
return false
100+
// If we don't manage inventory, we can always add to cart
101+
if (variant && !variant.manage_inventory) {
102+
return true
102103
}
103104

104-
if (variant && variant.allow_backorder === false) {
105+
// If we allow back orders on the variant, we can add to cart
106+
if (variant && variant.allow_backorder) {
105107
return true
106108
}
109+
110+
// If there is inventory available, we can add to cart
111+
if (variant?.inventory_quantity && variant.inventory_quantity > 0) {
112+
return true
113+
}
114+
115+
// Otherwise, we can't add to cart
116+
return false
107117
}, [variant])
108118

109119
const actionsRef = useRef<HTMLDivElement>(null)

0 commit comments

Comments
 (0)