@nuskin/ns-shop 5.20.13 → 5.20.14
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 +2 -2
- package/src/cart/cartItem.js +1 -2
- package/src/cart/cartService.js +7 -23
- package/src/cart/persistentCartService.js +1 -1
- package/src/cart/productService.js +11 -20
- package/src/order/orderAdapter.js +24 -26
- package/src/payment/paymentService.js +3 -9
- package/src/payment/paymentType.js +5 -2
- package/src/shipping/ShippingService.js +8 -18
- package/src/shop.js +0 -6
- package/src/firebase/fireBaseProductService.js +0 -724
- package/src/firebase/firebaseHealthUtil.js +0 -253
- package/src/firebase/firebaseProduct.js +0 -449
- package/src/firebase/firebaseProductCallbackUtil.js +0 -72
- package/src/firebase/firebaseProductDetail.js +0 -310
- package/src/firebase/firebaseProductParser.js +0 -289
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**
|
|
3
|
-
* This class is used to manage product data request callbacks for a given market. An example is that a page may ask
|
|
4
|
-
* for product data from firebase and while it is being loaded into local storage another request is made to get the
|
|
5
|
-
* product data for a particular product. Sense the product data has not loaded into local storage yet the request for
|
|
6
|
-
* product data will generate another firebase product data download. The FirebaseProductCallbackUtil is used to make
|
|
7
|
-
* sure only one firebase download is used and that all callbacks dependent on the download will be called after the
|
|
8
|
-
* product data is stored.
|
|
9
|
-
* @type {{market: string, loadedInLocalStorage: boolean, callbackQueue: Array, clear: FirebaseProductCallbackUtil.clear}}
|
|
10
|
-
*/
|
|
11
|
-
let FirebaseProductCallbackUtil = function(){
|
|
12
|
-
let callbackTable = new $.Hashtable();
|
|
13
|
-
let inProgressTable = new $.Hashtable();
|
|
14
|
-
|
|
15
|
-
// ---------------------------------------------
|
|
16
|
-
//
|
|
17
|
-
// Public Methods
|
|
18
|
-
//
|
|
19
|
-
// ---------------------------------------------
|
|
20
|
-
let publicMethods = {
|
|
21
|
-
addCallbackForMarket: function(market, callback){
|
|
22
|
-
if (callback) {
|
|
23
|
-
let callbacks = callbackTable.get(market);
|
|
24
|
-
|
|
25
|
-
if (callbacks == null) {
|
|
26
|
-
callbacks = [];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
callbacks.push(callback);
|
|
30
|
-
callbackTable.add(market, callbacks);
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
isProductDataDownLoadInProcess: function(market){
|
|
34
|
-
return inProgressTable.get(market) === true;
|
|
35
|
-
},
|
|
36
|
-
setProductDataDownloadInProcess: function(market, inProgress){
|
|
37
|
-
inProgressTable.add(market, inProgress);
|
|
38
|
-
|
|
39
|
-
if (inProgress == false){
|
|
40
|
-
processCallbacksForMarket(market);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// ---------------------------------------------
|
|
46
|
-
//
|
|
47
|
-
// Private Methods
|
|
48
|
-
//
|
|
49
|
-
// ---------------------------------------------
|
|
50
|
-
function processCallbacksForMarket(market){
|
|
51
|
-
let callbacks = callbackTable.get(market);
|
|
52
|
-
|
|
53
|
-
if (callbacks && callbacks.length > 0){
|
|
54
|
-
let callback;
|
|
55
|
-
|
|
56
|
-
while (callbacks.length > 0){
|
|
57
|
-
// Get and remove the callback.
|
|
58
|
-
callback = callbacks.pop();
|
|
59
|
-
|
|
60
|
-
// Execute the callback.
|
|
61
|
-
callback();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Remove the callbacks for the market.
|
|
65
|
-
callbackTable.remove(market);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return publicMethods;
|
|
70
|
-
}();
|
|
71
|
-
|
|
72
|
-
export default FirebaseProductCallbackUtil;
|
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import {PriceType} from '@nuskin/ns-product-lib';
|
|
3
|
-
|
|
4
|
-
let FirebaseProductDetail = function(product, currencyFormatter, currencyCode, countryCode){
|
|
5
|
-
let name;
|
|
6
|
-
let sku;
|
|
7
|
-
let shortDescription;
|
|
8
|
-
let longDescription;
|
|
9
|
-
let image;
|
|
10
|
-
let fullImage;
|
|
11
|
-
let size;
|
|
12
|
-
let nettoWeight;
|
|
13
|
-
|
|
14
|
-
let isOrder;
|
|
15
|
-
let isAdr;
|
|
16
|
-
|
|
17
|
-
let isCustomer;
|
|
18
|
-
let isPreferred;
|
|
19
|
-
let isDistributor;
|
|
20
|
-
|
|
21
|
-
let isPurchaseable;
|
|
22
|
-
let isPurchaseableForLTO;
|
|
23
|
-
let hasOrderOption;
|
|
24
|
-
let hasAdrOption;
|
|
25
|
-
let hasRetailSavings;
|
|
26
|
-
let hasWholesaleSavings;
|
|
27
|
-
let showPricing;
|
|
28
|
-
let showAdrPricing;
|
|
29
|
-
let priceClass;
|
|
30
|
-
|
|
31
|
-
let pricing = {
|
|
32
|
-
adr:
|
|
33
|
-
{
|
|
34
|
-
retail: "---",
|
|
35
|
-
retailSavings: "---",
|
|
36
|
-
preferred: "---",
|
|
37
|
-
preferredSavings: "---",
|
|
38
|
-
wholesale: "---",
|
|
39
|
-
wholesaleSavings: "---"
|
|
40
|
-
},
|
|
41
|
-
store:
|
|
42
|
-
{
|
|
43
|
-
retail: "---",
|
|
44
|
-
retailSavings: "---",
|
|
45
|
-
preferred: "---",
|
|
46
|
-
preferredSavings: "---"
|
|
47
|
-
},
|
|
48
|
-
web:
|
|
49
|
-
{
|
|
50
|
-
retail: "---",
|
|
51
|
-
preferred: "---",
|
|
52
|
-
wholesale: "---"
|
|
53
|
-
},
|
|
54
|
-
pointsValue:
|
|
55
|
-
{
|
|
56
|
-
pv: "---",
|
|
57
|
-
cv: "---",
|
|
58
|
-
points: "---"
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
if (product && product !== null) {
|
|
63
|
-
name = product.getTitle();
|
|
64
|
-
sku = product.sku;
|
|
65
|
-
shortDescription = product.getShortDescr();
|
|
66
|
-
longDescription = product.getLongDescr();
|
|
67
|
-
image = product.getThumbnail().replace('.img.64.64.png', '');
|
|
68
|
-
fullImage = product.getFullImage();
|
|
69
|
-
size = product.getSize();
|
|
70
|
-
nettoWeight = '';
|
|
71
|
-
|
|
72
|
-
isOrder = product.orderTypes.contains('order');
|
|
73
|
-
isAdr = product.orderTypes.contains('adr');
|
|
74
|
-
|
|
75
|
-
isCustomer = product.isCustomer();
|
|
76
|
-
isPreferred = product.isPreferredCustomer();
|
|
77
|
-
isDistributor = product.isDistributor();
|
|
78
|
-
|
|
79
|
-
isPurchaseable = product.available;
|
|
80
|
-
isPurchaseableForLTO = true;
|
|
81
|
-
hasOrderOption = product.hasOrderOption();
|
|
82
|
-
hasAdrOption = product.hasAdrOption();
|
|
83
|
-
hasRetailSavings = true;
|
|
84
|
-
hasWholesaleSavings = true;
|
|
85
|
-
showPricing = true;
|
|
86
|
-
showAdrPricing = true;
|
|
87
|
-
priceClass = '';
|
|
88
|
-
|
|
89
|
-
pricing.adr.retail = formatPrice(product.getPricing(PriceType.WADR));
|
|
90
|
-
pricing.adr.retailSavings = formatPrice(product.getPricing(PriceType.WRTL) - product.getPricing(PriceType.WADR));
|
|
91
|
-
pricing.adr.preferred = formatPrice(product.getPricing(PriceType.WADW));
|
|
92
|
-
pricing.adr.preferredSavings;
|
|
93
|
-
pricing.adr.wholesale = formatPrice(product.getPricing(PriceType.WADW));
|
|
94
|
-
pricing.adr.wholesaleSavings = formatPrice(product.getPricing(PriceType.WWHL) - product.getPricing(PriceType.WADW));
|
|
95
|
-
|
|
96
|
-
pricing.store.retail;
|
|
97
|
-
pricing.store.retailSavings;
|
|
98
|
-
pricing.store.preferred;
|
|
99
|
-
pricing.store.preferredSavings;
|
|
100
|
-
|
|
101
|
-
pricing.web.retail = formatPrice(product.getPricing(PriceType.WRTL));
|
|
102
|
-
pricing.web.preferred = formatPrice(product.getPricing(PriceType.WWHL));
|
|
103
|
-
pricing.web.wholesale = formatPrice(product.getPricing(PriceType.WWHL));
|
|
104
|
-
|
|
105
|
-
pricing.pointsValue.pv = product.getPv();
|
|
106
|
-
pricing.pointsValue.cv = product.getCv();
|
|
107
|
-
pricing.pointsValue.points;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function formatPrice(amount) {
|
|
111
|
-
return currencyFormatter.format(currencyCode, countryCode, amount);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// ---------------------------------------------
|
|
115
|
-
//
|
|
116
|
-
// Public Getter / Setter Methods
|
|
117
|
-
//
|
|
118
|
-
// ---------------------------------------------
|
|
119
|
-
Object.defineProperties(this, {
|
|
120
|
-
pricing: {
|
|
121
|
-
get: function () {
|
|
122
|
-
return pricing;
|
|
123
|
-
},
|
|
124
|
-
set: function (_pricing) {
|
|
125
|
-
pricing = _pricing;
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
name: {
|
|
129
|
-
get: function () {
|
|
130
|
-
return name;
|
|
131
|
-
},
|
|
132
|
-
set: function (_name) {
|
|
133
|
-
name = _name;
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
sku: {
|
|
137
|
-
get: function () {
|
|
138
|
-
return sku;
|
|
139
|
-
},
|
|
140
|
-
set: function (_sku) {
|
|
141
|
-
sku = _sku;
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
shortDescription: {
|
|
145
|
-
get: function () {
|
|
146
|
-
return shortDescription;
|
|
147
|
-
},
|
|
148
|
-
set: function (_shortDescription) {
|
|
149
|
-
shortDescription = _shortDescription;
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
longDescription: {
|
|
153
|
-
get: function () {
|
|
154
|
-
return longDescription;
|
|
155
|
-
},
|
|
156
|
-
set: function (_longDescription) {
|
|
157
|
-
longDescription = _longDescription;
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
image: {
|
|
161
|
-
get: function () {
|
|
162
|
-
return image;
|
|
163
|
-
},
|
|
164
|
-
set: function (_image) {
|
|
165
|
-
image = _image;
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
fullImage: {
|
|
169
|
-
get: function () {
|
|
170
|
-
return fullImage;
|
|
171
|
-
},
|
|
172
|
-
set: function (_fullImage) {
|
|
173
|
-
fullImage = _fullImage;
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
size: {
|
|
177
|
-
get: function () {
|
|
178
|
-
return size;
|
|
179
|
-
},
|
|
180
|
-
set: function (_size) {
|
|
181
|
-
size = _size;
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
// Order Type
|
|
186
|
-
isOrder: {
|
|
187
|
-
get: function () {
|
|
188
|
-
return isOrder;
|
|
189
|
-
},
|
|
190
|
-
set: function (_isOrder) {
|
|
191
|
-
isOrder = _isOrder;
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
isAdr: {
|
|
195
|
-
get: function () {
|
|
196
|
-
return isAdr;
|
|
197
|
-
},
|
|
198
|
-
set: function (_isAdr) {
|
|
199
|
-
isAdr = _isAdr;
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
// Customer Type
|
|
204
|
-
isCustomer: {
|
|
205
|
-
get: function () {
|
|
206
|
-
return isCustomer;
|
|
207
|
-
},
|
|
208
|
-
set: function (_isCustomer) {
|
|
209
|
-
isCustomer = _isCustomer;
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
isPreferred: {
|
|
213
|
-
get: function () {
|
|
214
|
-
return isPreferred;
|
|
215
|
-
},
|
|
216
|
-
set: function (_isPreferred) {
|
|
217
|
-
isPreferred = _isPreferred;
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
isDistributor: {
|
|
221
|
-
get: function () {
|
|
222
|
-
return isDistributor;
|
|
223
|
-
},
|
|
224
|
-
set: function (_isDistributor) {
|
|
225
|
-
isDistributor = _isDistributor;
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
|
|
229
|
-
// Status
|
|
230
|
-
isPurchaseable: {
|
|
231
|
-
get: function () {
|
|
232
|
-
if(isPurchaseable == "undefined") {
|
|
233
|
-
isPurchaseable = false;
|
|
234
|
-
}
|
|
235
|
-
return isPurchaseable;
|
|
236
|
-
},
|
|
237
|
-
set: function (_isPurchaseable) {
|
|
238
|
-
isPurchaseable = _isPurchaseable;
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
isPurchaseableForLTO: {
|
|
242
|
-
get: function () {
|
|
243
|
-
return isPurchaseableForLTO;
|
|
244
|
-
},
|
|
245
|
-
set: function (_isPurchaseableForLTO) {
|
|
246
|
-
isPurchaseableForLTO = _isPurchaseableForLTO;
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
hasOrderOption: {
|
|
250
|
-
get: function () {
|
|
251
|
-
return hasOrderOption;
|
|
252
|
-
},
|
|
253
|
-
set: function (_hasOrderOption) {
|
|
254
|
-
hasOrderOption = _hasOrderOption;
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
hasAdrOption: {
|
|
258
|
-
get: function () {
|
|
259
|
-
return hasAdrOption;
|
|
260
|
-
},
|
|
261
|
-
set: function (_hasAdrOption) {
|
|
262
|
-
hasAdrOption = _hasAdrOption;
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
hasRetailSavings: {
|
|
266
|
-
get: function () {
|
|
267
|
-
return hasRetailSavings;
|
|
268
|
-
},
|
|
269
|
-
set: function (_hasRetailSavings) {
|
|
270
|
-
hasRetailSavings = _hasRetailSavings;
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
|
-
hasWholesaleSavings: {
|
|
274
|
-
get: function () {
|
|
275
|
-
return hasWholesaleSavings;
|
|
276
|
-
},
|
|
277
|
-
set: function (_hasWholesaleSavings) {
|
|
278
|
-
hasWholesaleSavings = _hasWholesaleSavings;
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
showPricing: {
|
|
282
|
-
get: function () {
|
|
283
|
-
return showPricing;
|
|
284
|
-
},
|
|
285
|
-
set: function (_showPricing) {
|
|
286
|
-
showPricing = _showPricing;
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
showAdrPricing: {
|
|
290
|
-
get: function () {
|
|
291
|
-
return showAdrPricing;
|
|
292
|
-
},
|
|
293
|
-
set: function (_showAdrPricing) {
|
|
294
|
-
showAdrPricing = _showAdrPricing;
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
priceClass: {
|
|
298
|
-
get: function () {
|
|
299
|
-
return priceClass;
|
|
300
|
-
},
|
|
301
|
-
set: function (_priceClass) {
|
|
302
|
-
priceClass = _priceClass;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
nuskin.newShop.FirebaseProductDetail = FirebaseProductDetail;
|
|
309
|
-
|
|
310
|
-
export default FirebaseProductDetail;
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import {util} from '@nuskin/ns-util'
|
|
2
|
-
|
|
3
|
-
let FirebaseProductParser = function(productSku, language, firebaseProduct){
|
|
4
|
-
// Define the tags
|
|
5
|
-
let LANGUAGES = "languages";
|
|
6
|
-
let IMAGE_URL = "image";
|
|
7
|
-
let NAME = "name";
|
|
8
|
-
let LONG_DESCRIPTION = "long";
|
|
9
|
-
let SHORT_DESCRIPTION = "short";
|
|
10
|
-
let SIZE = "size";
|
|
11
|
-
|
|
12
|
-
let MARKET_DATA = "marketData";
|
|
13
|
-
let PRICING = "pricing";
|
|
14
|
-
let SCAN_QUALIFIED = "scanQualified";
|
|
15
|
-
let SEARCHABLE = "searchable";
|
|
16
|
-
let SEA_SHOPPE = "seashoppe";
|
|
17
|
-
let STATUS_CODE = "statusCode";
|
|
18
|
-
let ORDER_TYPE = "orderType";
|
|
19
|
-
let AVAILABLE = "available";
|
|
20
|
-
let CUST_TYPE = "custType";
|
|
21
|
-
|
|
22
|
-
let ADR_PREFERRED = "adrPrf";
|
|
23
|
-
let ADR_RETAIL = "adrRtl";
|
|
24
|
-
let ADR_WHOLESALE = "adrWhl";
|
|
25
|
-
let POINTS = "pts";
|
|
26
|
-
let PREFERRED = "prf";
|
|
27
|
-
let RETAIL = "rtl";
|
|
28
|
-
let WHOLESALE = "whl";
|
|
29
|
-
let WEB_ADR_RETAIL = "wAdrRtl";
|
|
30
|
-
let WEB_ADR_WHOLESALE = "wAdrWhl";
|
|
31
|
-
let WEB_PREFERRED = "wPrf";
|
|
32
|
-
let WEB_RETAIL = "wRtl";
|
|
33
|
-
let WEB_WHOLESALE = "wWhl";
|
|
34
|
-
let WEB_ADR_RETAIL_CV = "wAdrRtlCv";
|
|
35
|
-
let WEB_WHOLESALE_CV = "wWhlCv";
|
|
36
|
-
let WEB_ADR_RETAIL_PV = "wAdrRtlPv";
|
|
37
|
-
let WEB_WHOLESALE_PV = "wWhlPv";
|
|
38
|
-
|
|
39
|
-
let ORDER_TYPE_ADR = 'adr';
|
|
40
|
-
let ORDER_TYPE_ORDER = 'order';
|
|
41
|
-
|
|
42
|
-
let DISTRIBUTOR = '10';
|
|
43
|
-
let CUSTOMER = '20';
|
|
44
|
-
let PREFERRED_CUSTOMER = '30';
|
|
45
|
-
|
|
46
|
-
let sku;
|
|
47
|
-
let lang;
|
|
48
|
-
let product;
|
|
49
|
-
|
|
50
|
-
let languageStrings;
|
|
51
|
-
let marketData;
|
|
52
|
-
let pricing;
|
|
53
|
-
|
|
54
|
-
// ---------------------------------------------
|
|
55
|
-
//
|
|
56
|
-
// Public Methods
|
|
57
|
-
//
|
|
58
|
-
// ---------------------------------------------
|
|
59
|
-
let publicMethods = {
|
|
60
|
-
doesLanguageExistForProduct: function(language){
|
|
61
|
-
return product && product[LANGUAGES] && product[LANGUAGES][language];
|
|
62
|
-
},
|
|
63
|
-
doesMarketDataAndPricingExistForProduct: function(){
|
|
64
|
-
return product && product[MARKET_DATA] && product[PRICING];
|
|
65
|
-
},
|
|
66
|
-
getSku: function(){
|
|
67
|
-
return sku;
|
|
68
|
-
},
|
|
69
|
-
getLanguage: function(){
|
|
70
|
-
return lang;
|
|
71
|
-
},
|
|
72
|
-
getFullImageUrl: function(){
|
|
73
|
-
return languageStrings ? util.MobileUtils.checkPath(languageStrings[IMAGE_URL] + ".img.240.240.png", true) : "";
|
|
74
|
-
},
|
|
75
|
-
getImageUrl: function(){
|
|
76
|
-
return languageStrings ? util.MobileUtils.checkPath(languageStrings[IMAGE_URL] + ".img.64.64.png", true) : "";
|
|
77
|
-
},
|
|
78
|
-
getName: function(){
|
|
79
|
-
return languageStrings ? languageStrings[NAME] : "";
|
|
80
|
-
},
|
|
81
|
-
getSize: function(){
|
|
82
|
-
return languageStrings ? languageStrings[SIZE] : "";
|
|
83
|
-
},
|
|
84
|
-
getShortDescription: function(){
|
|
85
|
-
return languageStrings ? languageStrings[SHORT_DESCRIPTION] : "";
|
|
86
|
-
},
|
|
87
|
-
getLongDescription: function(){
|
|
88
|
-
return languageStrings ? languageStrings[LONG_DESCRIPTION] : "";
|
|
89
|
-
},
|
|
90
|
-
getScanQualified: function(){
|
|
91
|
-
return marketData ? marketData[SCAN_QUALIFIED] : false;
|
|
92
|
-
},
|
|
93
|
-
getAvailable: function(){
|
|
94
|
-
return marketData ? marketData[AVAILABLE] : false;
|
|
95
|
-
},
|
|
96
|
-
getSearchable: function(){
|
|
97
|
-
return marketData ? marketData[SEARCHABLE] : false;
|
|
98
|
-
},
|
|
99
|
-
getSeashoppe: function(){
|
|
100
|
-
return marketData ? marketData[SEA_SHOPPE] : false;
|
|
101
|
-
},
|
|
102
|
-
getStatusCode: function(){
|
|
103
|
-
return marketData ? marketData[STATUS_CODE] : 0;
|
|
104
|
-
},
|
|
105
|
-
getWebEnabled: function(){
|
|
106
|
-
// All firebase products are WEB enabled.
|
|
107
|
-
return true;
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
// ---------------------------------------------
|
|
111
|
-
//
|
|
112
|
-
// Pricing Methods
|
|
113
|
-
//
|
|
114
|
-
// ---------------------------------------------
|
|
115
|
-
getAdrPreferredPrice: function(){
|
|
116
|
-
return insureFloat(pricing && pricing[ADR_PREFERRED] ? pricing[ADR_PREFERRED] : "0.00");
|
|
117
|
-
},
|
|
118
|
-
getAdrRetailPrice: function(){
|
|
119
|
-
return insureFloat(pricing && pricing[ADR_RETAIL] ? pricing[ADR_RETAIL] : "0.00");
|
|
120
|
-
},
|
|
121
|
-
getAdrWholesalePrice: function(){
|
|
122
|
-
return insureFloat(pricing && pricing[ADR_WHOLESALE] ? pricing[ADR_WHOLESALE] : "0.00");
|
|
123
|
-
},
|
|
124
|
-
getPoints: function(){
|
|
125
|
-
return insureFloat(pricing && pricing[POINTS] ? pricing[POINTS] : "0.00");
|
|
126
|
-
},
|
|
127
|
-
getPreferredPrice: function(){
|
|
128
|
-
return insureFloat(pricing && pricing[PREFERRED] ? pricing[PREFERRED] : "0.00");
|
|
129
|
-
},
|
|
130
|
-
getRetailPrice: function(){
|
|
131
|
-
return insureFloat(pricing && pricing[RETAIL] ? pricing[RETAIL] : "0.00");
|
|
132
|
-
},
|
|
133
|
-
getWholesale: function(){
|
|
134
|
-
return insureFloat(pricing && pricing[WHOLESALE] ? pricing[WHOLESALE] : "0.00");
|
|
135
|
-
},
|
|
136
|
-
getWebAdrRetailPrice: function(){
|
|
137
|
-
return insureFloat(pricing && pricing[WEB_ADR_RETAIL] ? pricing[WEB_ADR_RETAIL] : "0.00");
|
|
138
|
-
},
|
|
139
|
-
getWebAdrWholesalePrice: function(){
|
|
140
|
-
return insureFloat(pricing && pricing[WEB_ADR_WHOLESALE] ? pricing[WEB_ADR_WHOLESALE] : "0.00");
|
|
141
|
-
},
|
|
142
|
-
getWebPreferredPrice: function(){
|
|
143
|
-
return insureFloat(pricing && pricing[WEB_PREFERRED] ? pricing[WEB_PREFERRED] : "0.00");
|
|
144
|
-
},
|
|
145
|
-
getWebRetailPrice: function(){
|
|
146
|
-
return insureFloat(pricing && pricing[WEB_RETAIL] ? pricing[WEB_RETAIL] : "0.00");
|
|
147
|
-
},
|
|
148
|
-
getWebWholesalePrice: function(){
|
|
149
|
-
return insureFloat(pricing && pricing[WEB_WHOLESALE] ? pricing[WEB_WHOLESALE] : "0.00");
|
|
150
|
-
},
|
|
151
|
-
getWebAdrRetailCv: function(){
|
|
152
|
-
return insureFloat(pricing && pricing[WEB_ADR_RETAIL_CV] ? pricing[WEB_ADR_RETAIL_CV] : "0.00");
|
|
153
|
-
},
|
|
154
|
-
getWebWholesaleCv: function(){
|
|
155
|
-
return insureFloat(pricing && pricing[WEB_WHOLESALE_CV] ? pricing[WEB_WHOLESALE_CV] : "0.00");
|
|
156
|
-
},
|
|
157
|
-
getWebAdrRetailPv: function(){
|
|
158
|
-
return insureFloat(pricing && pricing[WEB_ADR_RETAIL_PV] ? pricing[WEB_ADR_RETAIL_PV] : "0.00");
|
|
159
|
-
},
|
|
160
|
-
getWebWholesalePv: function(){
|
|
161
|
-
return insureFloat(pricing && pricing[WEB_WHOLESALE_PV] ? pricing[WEB_WHOLESALE_PV] : "0.00");
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
isOrderTypeADR: function(){
|
|
165
|
-
let isADR = false;
|
|
166
|
-
|
|
167
|
-
if (marketData) {
|
|
168
|
-
let orderType = marketData[ORDER_TYPE];
|
|
169
|
-
|
|
170
|
-
if (orderType) {
|
|
171
|
-
for (let i = 0; i < orderType.length; i++) {
|
|
172
|
-
if (orderType === ORDER_TYPE_ADR) {
|
|
173
|
-
isADR = true;
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return isADR;
|
|
181
|
-
},
|
|
182
|
-
isOrderTypeOrder: function(){
|
|
183
|
-
let isOrder = false;
|
|
184
|
-
|
|
185
|
-
if (marketData) {
|
|
186
|
-
let orderType = marketData[ORDER_TYPE];
|
|
187
|
-
|
|
188
|
-
if (orderType) {
|
|
189
|
-
for (let i = 0; i < orderType.length; i++) {
|
|
190
|
-
if (orderType === ORDER_TYPE_ORDER) {
|
|
191
|
-
isOrder = true;
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return isOrder;
|
|
199
|
-
},
|
|
200
|
-
getOrderTypes: function(){
|
|
201
|
-
return marketData && marketData[ORDER_TYPE] ? marketData[ORDER_TYPE] : [];
|
|
202
|
-
},
|
|
203
|
-
isCustomerTypeDistributor: function(){
|
|
204
|
-
let isDistributor = false;
|
|
205
|
-
|
|
206
|
-
if (marketData) {
|
|
207
|
-
let custType = marketData[CUST_TYPE];
|
|
208
|
-
|
|
209
|
-
if (custType) {
|
|
210
|
-
for (let i = 0; i < custType.length; i++) {
|
|
211
|
-
if (custType === DISTRIBUTOR) {
|
|
212
|
-
isDistributor = true;
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return isDistributor;
|
|
220
|
-
},
|
|
221
|
-
isCustomer: function(){
|
|
222
|
-
let isCustomer = false;
|
|
223
|
-
|
|
224
|
-
if (marketData) {
|
|
225
|
-
let custType = marketData[CUST_TYPE];
|
|
226
|
-
|
|
227
|
-
if (custType) {
|
|
228
|
-
for (let i = 0; i < custType.length; i++) {
|
|
229
|
-
if (custType === CUSTOMER) {
|
|
230
|
-
isCustomer = true;
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return isCustomer;
|
|
238
|
-
},
|
|
239
|
-
isPreferredCustomer: function(){
|
|
240
|
-
let isPreferred = false;
|
|
241
|
-
|
|
242
|
-
if (marketData) {
|
|
243
|
-
let custType = marketData[CUST_TYPE];
|
|
244
|
-
|
|
245
|
-
if (custType) {
|
|
246
|
-
for (let i = 0; i < custType.length; i++) {
|
|
247
|
-
if (custType === PREFERRED_CUSTOMER) {
|
|
248
|
-
isPreferred = true;
|
|
249
|
-
break;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return isPreferred;
|
|
256
|
-
},
|
|
257
|
-
getCustomerTypes: function(){
|
|
258
|
-
return marketData && marketData[CUST_TYPE] ? marketData[CUST_TYPE] : [];
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
// ---------------------------------------------
|
|
263
|
-
//
|
|
264
|
-
// Private Methods
|
|
265
|
-
//
|
|
266
|
-
// ---------------------------------------------
|
|
267
|
-
function createParser(productSku, language, firebaseProduct){
|
|
268
|
-
sku = productSku;
|
|
269
|
-
lang = language;
|
|
270
|
-
product = firebaseProduct;
|
|
271
|
-
|
|
272
|
-
if (product) {
|
|
273
|
-
languageStrings = product[LANGUAGES] ? product[LANGUAGES][lang] : undefined;
|
|
274
|
-
marketData = product[MARKET_DATA];
|
|
275
|
-
pricing = product[PRICING];
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
function insureFloat(price){
|
|
279
|
-
let floatPrice = parseFloat(price);
|
|
280
|
-
return isNaN(floatPrice) ? 0.00 : floatPrice;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// Construct the object.
|
|
284
|
-
createParser(productSku, language, firebaseProduct);
|
|
285
|
-
|
|
286
|
-
return publicMethods;
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
export default FirebaseProductParser;
|