cloudcommerce 0.0.97 → 0.0.98
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/packages/api/package.json +1 -1
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/tiny-erp/lib/event-to-tiny.js +94 -94
- package/packages/apps/tiny-erp/lib/index.js +1 -1
- package/packages/apps/tiny-erp/lib/integration/after-tiny-queue.js +74 -71
- package/packages/apps/tiny-erp/lib/integration/export-order-to-tiny.js +73 -70
- package/packages/apps/tiny-erp/lib/integration/export-product-to-tiny.js +53 -49
- package/packages/apps/tiny-erp/lib/integration/helpers/format-tiny-date.js +3 -3
- package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js +75 -76
- package/packages/apps/tiny-erp/lib/integration/import-product-from-tiny.js +140 -137
- package/packages/apps/tiny-erp/lib/integration/parsers/order-from-tiny.js +39 -40
- package/packages/apps/tiny-erp/lib/integration/parsers/order-to-tiny.js +178 -173
- package/packages/apps/tiny-erp/lib/integration/parsers/product-from-tiny.js +171 -173
- package/packages/apps/tiny-erp/lib/integration/parsers/product-to-tiny.js +127 -123
- package/packages/apps/tiny-erp/lib/integration/parsers/status-from-tiny.js +32 -32
- package/packages/apps/tiny-erp/lib/integration/parsers/status-to-tiny.js +37 -37
- package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js +43 -42
- package/packages/apps/tiny-erp/lib/tiny-erp.js +6 -8
- package/packages/apps/tiny-erp/lib/tiny-webhook.js +73 -76
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/config/package.json +1 -1
- package/packages/events/package.json +1 -1
- package/packages/firebase/lib/config.js +27 -25
- package/packages/firebase/lib/const.js +3 -2
- package/packages/firebase/lib/env.js +2 -1
- package/packages/firebase/lib/handlers/check-store-events.js +146 -145
- package/packages/firebase/lib/helpers/pubsub.js +20 -18
- package/packages/firebase/lib/helpers/update-app-data.js +38 -38
- package/packages/firebase/lib/index.js +9 -7
- package/packages/firebase/lib/init.js +2 -1
- package/packages/firebase/package.json +1 -1
- package/packages/modules/lib/firebase/ajv.js +19 -24
- package/packages/modules/lib/firebase/call-app-module.js +116 -110
- package/packages/modules/lib/firebase/checkout.js +151 -152
- package/packages/modules/lib/firebase/functions-checkout/fix-items.js +194 -187
- package/packages/modules/lib/firebase/functions-checkout/get-custumerId.js +25 -26
- package/packages/modules/lib/firebase/functions-checkout/handle-order-transaction.js +110 -109
- package/packages/modules/lib/firebase/functions-checkout/new-order.js +177 -177
- package/packages/modules/lib/firebase/functions-checkout/request-to-module.js +59 -59
- package/packages/modules/lib/firebase/functions-checkout/utils.js +195 -197
- package/packages/modules/lib/firebase/handle-module.js +144 -146
- package/packages/modules/lib/firebase/proxy-apps.js +2 -1
- package/packages/modules/lib/firebase/serve-modules-api.js +52 -53
- package/packages/modules/lib/firebase.js +4 -6
- package/packages/modules/lib/index.js +12 -15
- package/packages/modules/package.json +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/package.json +1 -1
- package/packages/storefront/dist/client/LoginOffcanvas.daf3f717.js +1 -0
- package/packages/storefront/dist/client/admin/config.json +1 -0
- package/packages/storefront/dist/client/assets/_...522e6bf2.css +4 -0
- package/packages/storefront/dist/client/assets/_...a48b75c7.css +1 -0
- package/packages/storefront/dist/client/assets/cms-preview.css +274 -0
- package/packages/storefront/dist/client/assets/cms.css +114 -0
- package/packages/storefront/dist/client/assets/cvv.png +0 -0
- package/packages/storefront/dist/client/assets/icons/bootstrap-icons/font/storefront-icons.woff2 +0 -0
- package/packages/storefront/dist/client/assets/icons/feather-icons/font/storefront-icons.woff2 +0 -0
- package/packages/storefront/dist/client/assets/icons/font-awesome/font/storefront-icons.woff2 +0 -0
- package/packages/storefront/dist/client/assets/icons/line-awesome/font/storefront-icons.woff2 +0 -0
- package/packages/storefront/dist/client/assets/icons/tabler-icons/font/storefront-icons.woff2 +0 -0
- package/packages/storefront/dist/client/assets/img-placeholder.png +0 -0
- package/packages/storefront/dist/client/assets/payments.png +0 -0
- package/packages/storefront/dist/client/assets/ssl-safe.png +0 -0
- package/packages/storefront/dist/client/chunks/LoginForm.d9251274.js +1066 -0
- package/packages/storefront/dist/client/chunks/LoginOffcanvas.07fe6492.js +1 -0
- package/packages/storefront/dist/client/chunks/index.esm.84a649c7.js +331 -0
- package/packages/storefront/dist/client/chunks/preload-helper.f15ab524.js +1 -0
- package/packages/storefront/dist/client/chunks/runtime-dom.esm-bundler.738639ee.js +1 -0
- package/packages/storefront/dist/client/chunks/workbox-window.prod.es5.4b654ae6.js +2 -0
- package/packages/storefront/dist/client/client.b552d86a.js +1 -0
- package/packages/storefront/dist/client/hoisted.054c36ac.js +1 -0
- package/packages/storefront/dist/client/img/icon.png +0 -0
- package/packages/storefront/dist/client/img/large-icon.png +0 -0
- package/packages/storefront/dist/client/img/uploads/banner1.png +0 -0
- package/packages/storefront/dist/client/img/uploads/banner2.png +0 -0
- package/packages/storefront/dist/client/img/uploads/banner2.webp +0 -0
- package/packages/storefront/dist/client/img/uploads/favicon.png +0 -0
- package/packages/storefront/dist/client/img/uploads/headless.png +0 -0
- package/packages/storefront/dist/client/img/uploads/headphone.png +0 -0
- package/packages/storefront/dist/client/img/uploads/headphone.webp +0 -0
- package/packages/storefront/dist/client/img/uploads/icon.png +0 -0
- package/packages/storefront/dist/client/img/uploads/large-icon.png +0 -0
- package/packages/storefront/dist/client/img/uploads/logo.png +0 -0
- package/packages/storefront/dist/client/img/uploads/logo.webp +0 -0
- package/packages/storefront/dist/client/img/uploads/og-image.png +0 -0
- package/packages/storefront/dist/client/img/uploads/passion.png +0 -0
- package/packages/storefront/dist/client/img/uploads/passion.webp +0 -0
- package/packages/storefront/dist/client/img/uploads/pwa-reliable.png +0 -0
- package/packages/storefront/dist/client/img/uploads/rect8589.png +0 -0
- package/packages/storefront/dist/client/img/uploads/rect859.png +0 -0
- package/packages/storefront/dist/client/img/uploads/rect89.png +0 -0
- package/packages/storefront/dist/client/img/uploads/rect89.webp +0 -0
- package/packages/storefront/dist/client/img/uploads/ssl-safe.png +0 -0
- package/packages/storefront/dist/client/manifest.webmanifest +1 -0
- package/packages/storefront/dist/client/page.3aa82516.js +1 -0
- package/packages/storefront/dist/client/robots.txt +8 -0
- package/packages/storefront/dist/client/sw.js +1 -0
- package/packages/storefront/dist/client/workbox-6f0d1f78.js +1 -0
- package/packages/storefront/dist/client/~partytown/partytown-atomics.js +2 -0
- package/packages/storefront/dist/client/~partytown/partytown-media.js +2 -0
- package/packages/storefront/dist/client/~partytown/partytown-sw.js +2 -0
- package/packages/storefront/dist/client/~partytown/partytown.js +2 -0
- package/packages/storefront/dist/server/entry.mjs +2852 -0
- package/packages/storefront/dist/server/manifest.webmanifest +1 -0
- package/packages/storefront/dist/server/registerSW.js +1 -0
- package/packages/storefront/package.json +1 -1
- package/packages/storefront/src/lib/layouts/PagesHeader.astro +2 -1
- package/packages/types/package.json +1 -1
|
@@ -1,200 +1,207 @@
|
|
|
1
1
|
import api from '@cloudcommerce/api';
|
|
2
|
-
|
|
3
2
|
export default async (checkoutItems) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
// run item by item
|
|
18
|
-
for (let i = 0; i < items.length; i++) {
|
|
19
|
-
// i, item scoped
|
|
20
|
-
const item = items[i];
|
|
21
|
-
const removeItem = () => {
|
|
22
|
-
// remove invalid item from list
|
|
23
|
-
items.splice(i, 1);
|
|
24
|
-
doFinally();
|
|
25
|
-
};
|
|
26
|
-
if (!item.quantity) {
|
|
27
|
-
// ignore items without quantity or zero
|
|
28
|
-
removeItem();
|
|
29
|
-
i -= 1;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const proceedItem = () => {
|
|
33
|
-
// additions to final price
|
|
34
|
-
if (Array.isArray(item.customizations)) {
|
|
35
|
-
item.customizations.forEach((customization) => {
|
|
36
|
-
if (item.final_price) {
|
|
37
|
-
if (customization.add_to_price) {
|
|
38
|
-
const { type, addition } = customization.add_to_price;
|
|
39
|
-
item.final_price += type === 'fixed'
|
|
40
|
-
? addition
|
|
41
|
-
: ((item.price * addition) / 100);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// done
|
|
47
|
-
doFinally();
|
|
3
|
+
const items = [...checkoutItems];
|
|
4
|
+
// get each cart item
|
|
5
|
+
// count done processes
|
|
6
|
+
let itemsDone = 0;
|
|
7
|
+
const itemsTodo = items.length;
|
|
8
|
+
// eslint-disable-next-line consistent-return
|
|
9
|
+
const doFinally = () => {
|
|
10
|
+
// after each item
|
|
11
|
+
itemsDone += 1;
|
|
12
|
+
if (itemsDone === itemsTodo) {
|
|
13
|
+
return items;
|
|
14
|
+
}
|
|
48
15
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (variation) {
|
|
64
|
-
// merge product body with variation object
|
|
65
|
-
body = Object.assign(product, variation);
|
|
66
|
-
}
|
|
16
|
+
// run item by item
|
|
17
|
+
for (let i = 0; i < items.length; i++) {
|
|
18
|
+
// i, item scoped
|
|
19
|
+
const item = items[i];
|
|
20
|
+
const removeItem = () => {
|
|
21
|
+
// remove invalid item from list
|
|
22
|
+
items.splice(i, 1);
|
|
23
|
+
doFinally();
|
|
24
|
+
};
|
|
25
|
+
if (!item.quantity) {
|
|
26
|
+
// ignore items without quantity or zero
|
|
27
|
+
removeItem();
|
|
28
|
+
i -= 1;
|
|
29
|
+
continue;
|
|
67
30
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
'sku',
|
|
82
|
-
'name',
|
|
83
|
-
'currency_id',
|
|
84
|
-
'currency_symbol',
|
|
85
|
-
'price',
|
|
86
|
-
'dimensions',
|
|
87
|
-
'weight',
|
|
88
|
-
'production_time',
|
|
89
|
-
].forEach((prop) => {
|
|
90
|
-
if (body && body[prop] !== undefined) {
|
|
91
|
-
item[prop] = body[prop];
|
|
31
|
+
const proceedItem = () => {
|
|
32
|
+
// additions to final price
|
|
33
|
+
if (Array.isArray(item.customizations)) {
|
|
34
|
+
item.customizations.forEach((customization) => {
|
|
35
|
+
if (item.final_price) {
|
|
36
|
+
if (customization.add_to_price) {
|
|
37
|
+
const { type, addition } = customization.add_to_price;
|
|
38
|
+
item.final_price += type === 'fixed'
|
|
39
|
+
? addition
|
|
40
|
+
: ((item.price * addition) / 100);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
92
44
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
// prevent error with repeated flags
|
|
100
|
-
const flags = [];
|
|
101
|
-
item.flags.forEach((flag) => {
|
|
102
|
-
if (!flags.includes(flag)) {
|
|
103
|
-
flags.push(flag);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
item.flags = flags;
|
|
107
|
-
}
|
|
108
|
-
//
|
|
109
|
-
// item.final_price = getPrice(body);
|
|
110
|
-
proceedItem();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const checkKitProduct = (kitProduct, kitProductId) => {
|
|
115
|
-
if (item.kit_product) {
|
|
116
|
-
if (kitProduct.available && kitProduct.kit_composition) {
|
|
117
|
-
// check kit composition and quantities
|
|
118
|
-
let packQuantity = 0;
|
|
119
|
-
let isFixedQuantity = true;
|
|
120
|
-
let kitItem;
|
|
121
|
-
kitProduct.kit_composition.forEach((currentKitItem) => {
|
|
122
|
-
if (currentKitItem.quantity) {
|
|
123
|
-
packQuantity += currentKitItem.quantity;
|
|
124
|
-
} else if (isFixedQuantity) {
|
|
125
|
-
isFixedQuantity = false;
|
|
45
|
+
// done
|
|
46
|
+
doFinally();
|
|
47
|
+
};
|
|
48
|
+
const checkItem = (product) => {
|
|
49
|
+
if (!product.available) {
|
|
50
|
+
removeItem();
|
|
126
51
|
}
|
|
127
|
-
|
|
128
|
-
|
|
52
|
+
else {
|
|
53
|
+
let body;
|
|
54
|
+
// check variation if any
|
|
55
|
+
if (!item.variation_id) {
|
|
56
|
+
body = product;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// find respective variation
|
|
60
|
+
let variation;
|
|
61
|
+
if (product.variations) {
|
|
62
|
+
variation = product.variations.find((variationFind) => variationFind._id === item.variation_id);
|
|
63
|
+
}
|
|
64
|
+
if (variation) {
|
|
65
|
+
// merge product body with variation object
|
|
66
|
+
body = Object.assign(product, variation);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// logger.log(body._id)
|
|
70
|
+
if (!body || (body.min_quantity && body.min_quantity > item.quantity)) {
|
|
71
|
+
// cannot handle current item
|
|
72
|
+
// invalid variation or quantity lower then minimum
|
|
73
|
+
removeItem();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// check quantity
|
|
77
|
+
if (body.quantity && body.quantity < item.quantity) {
|
|
78
|
+
// reduce to max available quantity
|
|
79
|
+
item.quantity = body.quantity;
|
|
80
|
+
}
|
|
81
|
+
// extend item properties with body
|
|
82
|
+
[
|
|
83
|
+
'sku',
|
|
84
|
+
'name',
|
|
85
|
+
'currency_id',
|
|
86
|
+
'currency_symbol',
|
|
87
|
+
'price',
|
|
88
|
+
'dimensions',
|
|
89
|
+
'weight',
|
|
90
|
+
'production_time',
|
|
91
|
+
].forEach((prop) => {
|
|
92
|
+
if (body && body[prop] !== undefined) {
|
|
93
|
+
item[prop] = body[prop];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
// price is required
|
|
97
|
+
if (!item.price) {
|
|
98
|
+
item.price = 0;
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(item.flags)) {
|
|
101
|
+
// prevent error with repeated flags
|
|
102
|
+
const flags = [];
|
|
103
|
+
item.flags.forEach((flag) => {
|
|
104
|
+
if (!flags.includes(flag)) {
|
|
105
|
+
flags.push(flag);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
item.flags = flags;
|
|
109
|
+
}
|
|
110
|
+
//
|
|
111
|
+
// item.final_price = getPrice(body);
|
|
112
|
+
proceedItem();
|
|
113
|
+
}
|
|
129
114
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
115
|
+
};
|
|
116
|
+
const checkKitProduct = (kitProduct, kitProductId) => {
|
|
117
|
+
if (item.kit_product) {
|
|
118
|
+
if (kitProduct.available && kitProduct.kit_composition) {
|
|
119
|
+
// check kit composition and quantities
|
|
120
|
+
let packQuantity = 0;
|
|
121
|
+
let isFixedQuantity = true;
|
|
122
|
+
let kitItem;
|
|
123
|
+
kitProduct.kit_composition.forEach((currentKitItem) => {
|
|
124
|
+
if (currentKitItem.quantity) {
|
|
125
|
+
packQuantity += currentKitItem.quantity;
|
|
126
|
+
}
|
|
127
|
+
else if (isFixedQuantity) {
|
|
128
|
+
isFixedQuantity = false;
|
|
129
|
+
}
|
|
130
|
+
if (currentKitItem._id === item.product_id) {
|
|
131
|
+
kitItem = currentKitItem;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
if (!isFixedQuantity) {
|
|
135
|
+
// use parent product min quantity
|
|
136
|
+
packQuantity = kitProduct.min_quantity || 0;
|
|
137
|
+
}
|
|
138
|
+
if (kitItem && (kitItem.quantity === undefined
|
|
136
139
|
|| item.quantity % kitItem.quantity === 0)) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
140
|
+
// valid kit item and quantity
|
|
141
|
+
let kitTotalQuantity = 0;
|
|
142
|
+
items.forEach((itemFind) => {
|
|
143
|
+
if (itemFind.kit_product && itemFind.kit_product._id === kitProductId) {
|
|
144
|
+
kitTotalQuantity += itemFind.quantity;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
const minPacks = kitItem.quantity
|
|
148
|
+
? item.quantity / kitItem.quantity
|
|
149
|
+
: 1;
|
|
150
|
+
if (kitTotalQuantity && kitTotalQuantity % (minPacks * packQuantity) === 0) {
|
|
151
|
+
// matched pack quantity
|
|
152
|
+
// item.kit_product.price = getPrice(kitProduct);
|
|
153
|
+
item.kit_product.pack_quantity = packQuantity;
|
|
154
|
+
if (item.kit_product.price) {
|
|
155
|
+
// set final price from kit
|
|
156
|
+
item.final_price = item.kit_product.price / packQuantity;
|
|
157
|
+
}
|
|
158
|
+
proceedItem();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// remove items with invalid kit
|
|
163
|
+
let index = 0;
|
|
164
|
+
while (index < items.length) {
|
|
165
|
+
const itemKit = items[index].kit_product;
|
|
166
|
+
if (itemKit && itemKit._id === kitProductId) {
|
|
167
|
+
items.splice(index, 1);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
index += 1;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
doFinally();
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
if (item.kit_product) {
|
|
177
|
+
// GET public kit product object
|
|
178
|
+
const kitProductId = item.kit_product._id;
|
|
179
|
+
// eslint-disable-next-line no-await-in-loop
|
|
180
|
+
const kitProduct = (await api.get(`products/${kitProductId}`, {
|
|
181
|
+
isNoAuth: true,
|
|
182
|
+
})).data;
|
|
183
|
+
if (kitProduct) {
|
|
184
|
+
checkKitProduct(kitProduct, kitProductId);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
removeItem();
|
|
156
188
|
}
|
|
157
|
-
}
|
|
158
189
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
190
|
+
else {
|
|
191
|
+
// GET public product object
|
|
192
|
+
// eslint-disable-next-line no-await-in-loop
|
|
193
|
+
const product = (await api.get(`products/${item.product_id}`, {
|
|
194
|
+
isNoAuth: true,
|
|
195
|
+
})).data;
|
|
196
|
+
if (product) {
|
|
197
|
+
checkItem(product);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
// remove cart item
|
|
201
|
+
removeItem();
|
|
202
|
+
}
|
|
168
203
|
}
|
|
169
|
-
doFinally();
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
if (item.kit_product) {
|
|
173
|
-
// GET public kit product object
|
|
174
|
-
const kitProductId = item.kit_product._id;
|
|
175
|
-
// eslint-disable-next-line no-await-in-loop
|
|
176
|
-
const kitProduct = (await api.get(`products/${kitProductId}`, {
|
|
177
|
-
isNoAuth: true,
|
|
178
|
-
})).data;
|
|
179
|
-
if (kitProduct) {
|
|
180
|
-
checkKitProduct(kitProduct, kitProductId);
|
|
181
|
-
} else {
|
|
182
|
-
removeItem();
|
|
183
|
-
}
|
|
184
|
-
} else {
|
|
185
|
-
// GET public product object
|
|
186
|
-
// eslint-disable-next-line no-await-in-loop
|
|
187
|
-
const product = (await api.get(`products/${item.product_id}`, {
|
|
188
|
-
isNoAuth: true,
|
|
189
|
-
})).data;
|
|
190
|
-
if (product) {
|
|
191
|
-
checkItem(product);
|
|
192
|
-
} else {
|
|
193
|
-
// remove cart item
|
|
194
|
-
removeItem();
|
|
195
|
-
}
|
|
196
204
|
}
|
|
197
|
-
|
|
198
|
-
return items;
|
|
205
|
+
return items;
|
|
199
206
|
};
|
|
200
|
-
|
|
207
|
+
//# sourceMappingURL=fix-items.js.map
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
import api from '@cloudcommerce/api';
|
|
2
2
|
import { logger } from 'firebase-functions';
|
|
3
|
-
|
|
4
3
|
const findCustomerByEmail = async (email, accessToken) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
try {
|
|
5
|
+
const { data } = await api.get(`customers?main_email=${email}`, {
|
|
6
|
+
accessToken,
|
|
7
|
+
});
|
|
8
|
+
if (data.result.length) {
|
|
9
|
+
return data.result[0]._id;
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
logger.error(e);
|
|
15
|
+
return null;
|
|
11
16
|
}
|
|
12
|
-
return null;
|
|
13
|
-
} catch (e) {
|
|
14
|
-
logger.error(e);
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
17
|
};
|
|
18
|
-
|
|
19
18
|
export default (accessToken, customer) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
if (customer) {
|
|
20
|
+
if (!customer._id) {
|
|
21
|
+
// try to find customer by e-mail
|
|
22
|
+
// GET customer object
|
|
23
|
+
return customer.main_email ? findCustomerByEmail(customer.main_email, accessToken) : null;
|
|
24
|
+
// use first resulted customer ID
|
|
25
|
+
}
|
|
26
|
+
if (customer._id && (typeof customer._id === 'string') && customer._id.length === 24) {
|
|
27
|
+
// customer ID already defined
|
|
28
|
+
return customer._id;
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
|
-
|
|
28
|
-
// customer ID already defined
|
|
29
|
-
return customer._id;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
31
|
+
return null;
|
|
33
32
|
};
|
|
34
|
-
|
|
33
|
+
//# sourceMappingURL=get-custumerId.js.map
|