File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
src/modules/products/components/product-actions Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -97,13 +97,23 @@ export default function ProductActions({
97
97
98
98
// check if the selected variant is in stock
99
99
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
102
103
}
103
104
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 ) {
105
107
return true
106
108
}
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
107
117
} , [ variant ] )
108
118
109
119
const actionsRef = useRef < HTMLDivElement > ( null )
You can’t perform that action at this time.
0 commit comments