@nuskin/cs-product-lib 1.0.9 → 1.0.10
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/package.json +1 -1
- package/src/formatKit.js +12 -12
package/package.json
CHANGED
package/src/formatKit.js
CHANGED
|
@@ -59,7 +59,7 @@ const parsePrice = (product = []) => {
|
|
|
59
59
|
|
|
60
60
|
const variants = requiredProducts?.map(p => {
|
|
61
61
|
const [firstVariant] = p?.product?.variants || []
|
|
62
|
-
return firstVariant
|
|
62
|
+
return {...firstVariant, quantity: p?.quantity}
|
|
63
63
|
})
|
|
64
64
|
|
|
65
65
|
const defaultValues = {
|
|
@@ -91,18 +91,18 @@ const parsePrice = (product = []) => {
|
|
|
91
91
|
wholesale : {}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
price.retail = Number(acc?.price?.retail || 0) + Number(curr?.price?.retail || 0)
|
|
95
|
-
price.retailSubscription = Number(acc?.price?.retailSubscription || 0) + Number(curr?.price?.retailSubscription || 0)
|
|
96
|
-
price.wholesale = Number(acc?.price?.wholesale || 0) + Number(curr?.price?.wholesale || 0)
|
|
97
|
-
price.wholesaleSubscription = Number(acc?.price?.wholesaleSubscription || 0) + Number(curr?.price?.wholesaleSubscription || 0)
|
|
94
|
+
price.retail = Number((acc?.price?.retail || 0)) + Number((curr?.price?.retail || 0) * (curr?.quantity || 1))
|
|
95
|
+
price.retailSubscription = Number(acc?.price?.retailSubscription || 0) + Number((curr?.price?.retailSubscription || 0) * (curr?.quantity || 1))
|
|
96
|
+
price.wholesale = Number(acc?.price?.wholesale || 0) + Number((curr?.price?.wholesale || 0) * (curr?.quantity || 1))
|
|
97
|
+
price.wholesaleSubscription = Number(acc?.price?.wholesaleSubscription || 0) + Number((curr?.price?.wholesaleSubscription || 0) * (curr?.quantity || 1))
|
|
98
98
|
price.currencyCode = curr?.price.currencyCode
|
|
99
99
|
|
|
100
|
-
points.subscription.cv = Number(acc?.points?.subscription?.cv || 0) + Number(curr?.points?.subscription?.cv || 0)
|
|
101
|
-
points.subscription.pv = Number(acc?.points?.subscription?.pv || 0) + Number(curr?.points?.subscription?.pv || 0)
|
|
102
|
-
points.subscription.sb = Number(acc?.points?.subscription?.sb || 0) + Number(curr?.points?.subscription?.sb || 0)
|
|
103
|
-
points.wholesale.cv = Number(acc?.points?.wholesale?.cv || 0) + Number(curr?.points?.wholesale?.cv || 0)
|
|
104
|
-
points.wholesale.pv = Number(acc?.points?.wholesale?.pv || 0) + Number(curr?.points?.wholesale?.pv || 0)
|
|
105
|
-
points.wholesale.sb = Number(acc?.points?.wholesale?.sb || 0) + Number(curr?.points?.wholesale?.sb || 0)
|
|
100
|
+
points.subscription.cv = Number(acc?.points?.subscription?.cv || 0) + Number((curr?.points?.subscription?.cv || 0) * (curr?.quantity || 1))
|
|
101
|
+
points.subscription.pv = Number(acc?.points?.subscription?.pv || 0) + Number((curr?.points?.subscription?.pv || 0) * (curr?.quantity || 1))
|
|
102
|
+
points.subscription.sb = Number(acc?.points?.subscription?.sb || 0) + Number((curr?.points?.subscription?.sb || 0) * (curr?.quantity || 1))
|
|
103
|
+
points.wholesale.cv = Number(acc?.points?.wholesale?.cv || 0) + Number((curr?.points?.wholesale?.cv || 0) * (curr?.quantity || 1))
|
|
104
|
+
points.wholesale.pv = Number(acc?.points?.wholesale?.pv || 0) + Number((curr?.points?.wholesale?.pv || 0) * (curr?.quantity || 1))
|
|
105
|
+
points.wholesale.sb = Number(acc?.points?.wholesale?.sb || 0) + Number((curr?.points?.wholesale?.sb || 0) * (curr?.quantity || 1))
|
|
106
106
|
|
|
107
107
|
return { price, points}
|
|
108
108
|
}, defaultValues)
|
|
@@ -120,7 +120,7 @@ const parseKitAvailableQuantity = (kit) => {
|
|
|
120
120
|
const parseBundleAvailableQuantity = (product) => {
|
|
121
121
|
try {
|
|
122
122
|
const {requiredProducts = []} = product|| {}
|
|
123
|
-
const quantities = requiredProducts
|
|
123
|
+
const quantities = requiredProducts.map(p=>p.product?.variants.map(a=>a.availableQuantity))
|
|
124
124
|
return Math.min(...quantities) || 0
|
|
125
125
|
} catch {
|
|
126
126
|
console.log("some error in availableQuantity")
|