@nuskin/mobile-cart
Advanced tools
Comparing version 3.0.10 to 3.0.11
@@ -245,8 +245,25 @@ "use strict"; | ||
}; | ||
/** | ||
* Checks the availableChannels or the purchaseTypes to determine if the item is a | ||
* subscription only item. This would be used if the oneTime flag was not passed in. | ||
* | ||
* @param item | ||
* @returns | ||
*/ | ||
const isItemSubscriptionOnly = item => { | ||
let subOnly = false; | ||
if (item.availableChannels) { | ||
var _item$availableChanne; | ||
subOnly = ((_item$availableChanne = item.availableChannels) === null || _item$availableChanne === void 0 ? void 0 : _item$availableChanne.length) > 0 && item.availableChannels[0] === 'subscription'; | ||
} else if (item.purchaseTypes) { | ||
subOnly = item.purchaseTypes.buyOnce === false && item.purchaseTypes.subscription === true; | ||
} | ||
return subOnly; | ||
}; | ||
const getEqBodyFromItem = (item, quantity, optionalBundleSkus) => { | ||
var _item$availableChanne; | ||
let body = { | ||
quantity, | ||
skus: [], | ||
isSubscription: ((_item$availableChanne = item.availableChannels) === null || _item$availableChanne === void 0 ? void 0 : _item$availableChanne.length) === 1 && item.availableChannels[0] === 'subscription' | ||
isSubscription: isItemSubscriptionOnly(item) | ||
}; | ||
@@ -315,3 +332,3 @@ if (body.isSubscription) { | ||
quantity = 1, | ||
oneTime = true, | ||
oneTime, | ||
agelocme = null, | ||
@@ -333,5 +350,3 @@ optionalBundleSkus = [] | ||
} else { | ||
data.push({ | ||
sku: item.sku | ||
}); | ||
data.push(item); | ||
} | ||
@@ -358,3 +373,3 @@ }); | ||
itemCount | ||
} = await api.addSkuToCart(dataItem.sku, quantity, authToken, oneTime, agelocme); | ||
} = await api.addSkuToCart(dataItem.sku, quantity, authToken, oneTime ?? !isItemSubscriptionOnly(dataItem), agelocme); | ||
setAnonymousCartId(anonymousCartId); | ||
@@ -361,0 +376,0 @@ setQuantity(itemCount); |
@@ -236,8 +236,25 @@ /* eslint-disable */ | ||
}; | ||
/** | ||
* Checks the availableChannels or the purchaseTypes to determine if the item is a | ||
* subscription only item. This would be used if the oneTime flag was not passed in. | ||
* | ||
* @param item | ||
* @returns | ||
*/ | ||
const isItemSubscriptionOnly = item => { | ||
let subOnly = false; | ||
if (item.availableChannels) { | ||
var _item$availableChanne; | ||
subOnly = ((_item$availableChanne = item.availableChannels) === null || _item$availableChanne === void 0 ? void 0 : _item$availableChanne.length) > 0 && item.availableChannels[0] === 'subscription'; | ||
} else if (item.purchaseTypes) { | ||
subOnly = item.purchaseTypes.buyOnce === false && item.purchaseTypes.subscription === true; | ||
} | ||
return subOnly; | ||
}; | ||
const getEqBodyFromItem = (item, quantity, optionalBundleSkus) => { | ||
var _item$availableChanne; | ||
let body = { | ||
quantity, | ||
skus: [], | ||
isSubscription: ((_item$availableChanne = item.availableChannels) === null || _item$availableChanne === void 0 ? void 0 : _item$availableChanne.length) === 1 && item.availableChannels[0] === 'subscription' | ||
isSubscription: isItemSubscriptionOnly(item) | ||
}; | ||
@@ -306,3 +323,3 @@ if (body.isSubscription) { | ||
quantity = 1, | ||
oneTime = true, | ||
oneTime, | ||
agelocme = null, | ||
@@ -324,5 +341,3 @@ optionalBundleSkus = [] | ||
} else { | ||
data.push({ | ||
sku: item.sku | ||
}); | ||
data.push(item); | ||
} | ||
@@ -349,3 +364,3 @@ }); | ||
itemCount | ||
} = await api.addSkuToCart(dataItem.sku, quantity, authToken, oneTime, agelocme); | ||
} = await api.addSkuToCart(dataItem.sku, quantity, authToken, oneTime ?? !isItemSubscriptionOnly(dataItem), agelocme); | ||
setAnonymousCartId(anonymousCartId); | ||
@@ -352,0 +367,0 @@ setQuantity(itemCount); |
{ | ||
"name": "@nuskin/mobile-cart", | ||
"private": false, | ||
"version": "3.0.10", | ||
"version": "3.0.11", | ||
"repository": { | ||
@@ -143,3 +143,3 @@ "type": "git", | ||
}, | ||
"commithash": "7585af6505cbc5a51726954cdfc67a190fecf7ba", | ||
"commithash": "f6794fd8ad71ab5e066cdfeb79c362f655622aa6", | ||
"author": { | ||
@@ -146,0 +146,0 @@ "name": "Treg Anderson", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
284240
3929