@gem-sdk/core 1.23.0-staging.270 → 1.23.0-staging.273
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/src/product/helpers/product.js +7 -0
- package/dist/cjs/helpers/variant.js +4 -5
- package/dist/cjs/hooks/useProduct.js +2 -1
- package/dist/esm/components/src/product/helpers/product.js +5 -0
- package/dist/esm/helpers/variant.js +4 -5
- package/dist/esm/hooks/useProduct.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const checkDefaultVariant = (product)=>{
|
|
4
|
+
return !product?.options?.length || product?.options?.length === 1 && product?.options?.[0]?.name === 'Title' && product?.options?.[0]?.values?.length === 1 && product?.options?.[0]?.values?.[0]?.label === 'Default Title';
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
exports.checkDefaultVariant = checkDefaultVariant;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var product = require('../components/src/product/helpers/product.js');
|
|
4
|
+
|
|
5
|
+
function checkInStock(variant, product$1) {
|
|
4
6
|
if (!variant) return false;
|
|
5
|
-
return variant?.inventoryQuantity && variant.inventoryQuantity > 0 && !
|
|
6
|
-
}
|
|
7
|
-
function isDefaultVariant(variant) {
|
|
8
|
-
return variant?.title === 'Default Title';
|
|
7
|
+
return variant?.inventoryQuantity && variant.inventoryQuantity > 0 && !product.checkDefaultVariant(product$1) || !variant?.manageInventory || variant.inventoryPolicy === 'CONTINUE';
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
exports.checkInStock = checkInStock;
|
|
@@ -149,7 +149,8 @@ const useCurrentVariant = ()=>{
|
|
|
149
149
|
};
|
|
150
150
|
const useCurrentVariantInStock = ()=>{
|
|
151
151
|
const currentVariant = useCurrentVariant();
|
|
152
|
-
|
|
152
|
+
const currentProduct = useProduct();
|
|
153
|
+
return variant.checkInStock(currentVariant, currentProduct);
|
|
153
154
|
};
|
|
154
155
|
const useVariantOutStock = (optionId, optionValue, options)=>{
|
|
155
156
|
const { selectedOptions } = useSelectedOption();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const checkDefaultVariant = (product)=>{
|
|
2
|
+
return !product?.options?.length || product?.options?.length === 1 && product?.options?.[0]?.name === 'Title' && product?.options?.[0]?.values?.length === 1 && product?.options?.[0]?.values?.[0]?.label === 'Default Title';
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export { checkDefaultVariant };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { checkDefaultVariant } from '../components/src/product/helpers/product.js';
|
|
2
|
+
|
|
3
|
+
function checkInStock(variant, product) {
|
|
2
4
|
if (!variant) return false;
|
|
3
|
-
return variant?.inventoryQuantity && variant.inventoryQuantity > 0 && !
|
|
4
|
-
}
|
|
5
|
-
function isDefaultVariant(variant) {
|
|
6
|
-
return variant?.title === 'Default Title';
|
|
5
|
+
return variant?.inventoryQuantity && variant.inventoryQuantity > 0 && !checkDefaultVariant(product) || !variant?.manageInventory || variant.inventoryPolicy === 'CONTINUE';
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
export { checkInStock };
|
|
@@ -147,7 +147,8 @@ const useCurrentVariant = ()=>{
|
|
|
147
147
|
};
|
|
148
148
|
const useCurrentVariantInStock = ()=>{
|
|
149
149
|
const currentVariant = useCurrentVariant();
|
|
150
|
-
|
|
150
|
+
const currentProduct = useProduct();
|
|
151
|
+
return checkInStock(currentVariant, currentProduct);
|
|
151
152
|
};
|
|
152
153
|
const useVariantOutStock = (optionId, optionValue, options)=>{
|
|
153
154
|
const { selectedOptions } = useSelectedOption();
|