@nuskin/ns-product-lib 2.13.3-cx24-5694.2 → 2.13.3-cx24-5694.3

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.13.3-cx24-5694.2",
3
+ "version": "2.13.3-cx24-5694.3",
4
4
  "description": "This project contains shared Product models and code between the backend and frontend.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -10,7 +10,7 @@
10
10
  */
11
11
  function originalPrice(product, isWholesale = false, isBundleKit = false) {
12
12
  const { price, totalPrice } = product;
13
- const productPrice = totalPrice ? totalPrice : price;
13
+ const productPrice = price ? price : totalPrice;
14
14
 
15
15
  if (isBundleKit) {
16
16
 
@@ -4,19 +4,18 @@
4
4
  * Map retail price
5
5
  * Map retailSales if it has sales/promotions
6
6
  * @param {obj} product
7
- * @param {boolean} isBundleKit
8
7
  * @return {number} retailPrice
9
8
  */
10
- function retailPrice(product, isBundleKit = false) {
9
+ function retailPrice(product) {
11
10
  const { price, totalPrice } = product;
12
- const productPrice = totalPrice ? totalPrice : price;
11
+ const productPrice = price ? price : totalPrice;
13
12
 
14
13
  if (productPrice.retailSales) {
15
14
 
16
15
  return productPrice.retailSales;
17
16
  }
18
17
 
19
- return isBundleKit ? productPrice.retailOriginal : productPrice.retail;
18
+ return productPrice.retail;
20
19
 
21
20
  }
22
21
 
@@ -8,7 +8,7 @@
8
8
  */
9
9
  function retailSubscriptionPrice(product) {
10
10
  const { price, totalPrice } = product;
11
- const productPrice = totalPrice ? totalPrice : price;
11
+ const productPrice = price ? price : totalPrice;
12
12
 
13
13
  if (productPrice.retailSales) {
14
14
 
@@ -4,18 +4,17 @@
4
4
  * Map wholesale price
5
5
  * Map wholesaleSales if it has sales/promotions
6
6
  * @param {*} product
7
- * @param {boolean} isBundleKit
8
7
  * @return {number} wholesalePrice
9
8
  */
10
- function wholeSalePrice(product, isBundleKit) {
9
+ function wholeSalePrice(product) {
11
10
  const { price, totalPrice } = product;
12
- const productPrice = totalPrice ? totalPrice : price;
11
+ const productPrice = price ? price : totalPrice;
13
12
 
14
13
  if (productPrice.wholesaleSales) {
15
14
  return productPrice.wholesaleSales;
16
15
  }
17
16
 
18
- return isBundleKit ? productPrice.wholesaleOriginal : productPrice.wholesale;
17
+ return productPrice.wholesale;
19
18
  }
20
19
 
21
20
  module.exports = wholeSalePrice;
@@ -8,7 +8,7 @@
8
8
  */
9
9
  function wholesaleSubscriptionPrice(product) {
10
10
  const { price, totalPrice } = product;
11
- const productPrice = totalPrice ? totalPrice : price;
11
+ const productPrice = price ? price : totalPrice;
12
12
 
13
13
  if (productPrice.wholesaleSales) {
14
14
 
@@ -86,14 +86,14 @@ async function getProduct(id, market, locale, config) {
86
86
  * @return {obj} prices
87
87
  */
88
88
  function mapPrices(product, isKitBundle = false) {
89
- const originalPrice = mapOriginalPrice(product, isKitBundle);
90
- const retailPrice = mapRetailPrice(product, isKitBundle);
91
- const wholesalePrice = mapWholesalePrice(product, isKitBundle);
92
- const originalWholeSalePrice = mapOriginalPrice(product, true, isKitBundle);
89
+ const originalPrice = mapOriginalPrice(product, false, isKitBundle) || 0;
90
+ const retailPrice = mapRetailPrice(product) || 0;
91
+ const wholesalePrice = mapWholesalePrice(product) || 0;
92
+ const originalWholeSalePrice = mapOriginalPrice(product, true, isKitBundle) || 0;
93
93
 
94
94
  //map subscription (ADR) prices
95
- const retailSubscriptionPrice = mapRetailSubscriptionPrice(product);
96
- const wholesaleSubscriptionPrice = mapWholesaleSubscriptionPrice(product);
95
+ const retailSubscriptionPrice = mapRetailSubscriptionPrice(product) || 0;
96
+ const wholesaleSubscriptionPrice = mapWholesaleSubscriptionPrice(product) || 0;
97
97
 
98
98
  return {
99
99
  originalPrice,
@@ -1,5 +1,5 @@
1
1
  const getProductByIdQuery = require('./getProductById');
2
2
 
3
3
  module.exports = {
4
- getProductById: getProductByIdQuery
4
+ getProductByIdQuery
5
5
  }