@things-factory/integration-sellercraft 4.2.3 → 4.2.8
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/dist-server/constants/order-status-mapping.js +18 -4
- package/dist-server/constants/order-status-mapping.js.map +1 -1
- package/dist-server/constants/platform.js +2 -1
- package/dist-server/constants/platform.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js +5 -2
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js +2 -2
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js +25 -8
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js +8 -4
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js.map +1 -1
- package/dist-server/routers/sellercraft-router.js +26 -17
- package/dist-server/routers/sellercraft-router.js.map +1 -1
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js +291 -233
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js.map +1 -1
- package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js +41 -23
- package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js.map +1 -1
- package/package.json +3 -3
- package/server/constants/order-status-mapping.ts +18 -3
- package/server/constants/platform.ts +2 -1
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.ts +6 -2
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.ts +2 -2
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts +34 -15
- package/server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts +8 -4
- package/server/routers/sellercraft-router.ts +23 -17
- package/server/service/marketplace-channel/marketplace-channel-order-mutation.ts +345 -271
- package/server/service/marketplace-channel/marketplace-channel-product-mutation.ts +38 -35
@@ -15,12 +15,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.MarketplaceChannelProductMutation = void 0;
|
16
16
|
const type_graphql_1 = require("type-graphql");
|
17
17
|
const typeorm_1 = require("typeorm");
|
18
|
-
const marketplace_channel_1 = require("./marketplace-channel");
|
19
18
|
const env_1 = require("@things-factory/env");
|
20
19
|
const integration_marketplace_1 = require("@things-factory/integration-marketplace");
|
21
20
|
const sellercraft_channel_integration_api_1 = require("../../controllers/sellercraft-channel-integration-api");
|
21
|
+
const marketplace_channel_1 = require("./marketplace-channel");
|
22
22
|
let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation {
|
23
23
|
async syncAllMarketplaceChannelProducts(context) {
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
24
25
|
const sellercraftChannelIntegrationConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
|
25
26
|
const { tokenCraftApiKey: apiKey, getShopsTokenCraftUrl } = sellercraftChannelIntegrationConfig;
|
26
27
|
const channels = await (0, typeorm_1.getRepository)(marketplace_channel_1.MarketplaceChannel).find();
|
@@ -40,11 +41,12 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
40
41
|
var shops = shopsResponse.shops;
|
41
42
|
for (var j = 0; j < shops.length; j++) {
|
42
43
|
var store = {
|
43
|
-
accessKey: shops[j].credential.consumer_key,
|
44
|
-
accessSecret: shops[j].credential.consumer_secret,
|
45
|
-
storeURL: shops[j].credential.store_url,
|
44
|
+
accessKey: ((_b = (_a = shops[j]) === null || _a === void 0 ? void 0 : _a.credential) === null || _b === void 0 ? void 0 : _b.consumer_key) || '',
|
45
|
+
accessSecret: ((_d = (_c = shops[j]) === null || _c === void 0 ? void 0 : _c.credential) === null || _d === void 0 ? void 0 : _d.consumer_secret) || '',
|
46
|
+
storeURL: ((_f = (_e = shops[j]) === null || _e === void 0 ? void 0 : _e.credential) === null || _f === void 0 ? void 0 : _f.store_url) || '',
|
46
47
|
platform: channels[i].name,
|
47
|
-
accessToken: shops[j].credential.access_token
|
48
|
+
accessToken: (_h = (_g = shops[j]) === null || _g === void 0 ? void 0 : _g.credential) === null || _h === void 0 ? void 0 : _h.access_token,
|
49
|
+
channelShopId: (_j = shops[j]) === null || _j === void 0 ? void 0 : _j.channel_shop_id
|
48
50
|
};
|
49
51
|
let countryCode = shops[j].country_code;
|
50
52
|
let channelCode = shops[j].org_prefix;
|
@@ -53,26 +55,32 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
53
55
|
var sellercraftStore = Object.assign(Object.assign({}, store), { platform: 'sellercraftChannelIntegration' });
|
54
56
|
const productResult = [];
|
55
57
|
let totalPages = 1;
|
56
|
-
|
58
|
+
let limit = 50;
|
59
|
+
let parentLinks = [];
|
57
60
|
for (let page = 0; page < totalPages; page++) {
|
58
|
-
const { results, total } = await integration_marketplace_1.StoreAPI.getStoreProducts(store, {
|
61
|
+
const { results, total, parentLinkList } = await integration_marketplace_1.StoreAPI.getStoreProducts(store, {
|
59
62
|
pagination: { page, limit }
|
60
63
|
});
|
61
64
|
totalPages = Math.ceil(total / limit);
|
62
65
|
productResult.push(...results);
|
66
|
+
if (store.platform == 'magento')
|
67
|
+
parentLinks.push(...parentLinkList);
|
63
68
|
}
|
64
69
|
const categoryResult = [];
|
65
70
|
let totalPagesCategory = 1;
|
66
|
-
|
71
|
+
let limitCategory = 100;
|
67
72
|
for (let page = 0; page < totalPagesCategory; page++) {
|
68
|
-
const { results, total } = await integration_marketplace_1.StoreAPI.getStoreProductCategories(store, {
|
73
|
+
const { results, total } = await integration_marketplace_1.StoreAPI.getStoreProductCategories(store, {
|
74
|
+
pagination: { page, limitCategory }
|
75
|
+
});
|
69
76
|
totalPagesCategory = Math.ceil(total / limitCategory);
|
70
77
|
categoryResult.push(...results);
|
71
78
|
}
|
72
79
|
let mappedProducts = productResult.map(item => {
|
73
|
-
|
80
|
+
var _a;
|
81
|
+
let { categoryId, itemId: productId, name, brand, isVerified, images, attributes, variations } = item;
|
74
82
|
variations = variations.map(variation => {
|
75
|
-
let { variationSku, variationId, name, isEnabled: isEnabled,
|
83
|
+
let { variationSku, variationId, name, isEnabled: isEnabled, isSellable: isSellable, attributes, stockLocked, qty: stockReported, costPrice: fullPrice, sellPrice: priceDiscounted, length, width, height, weight } = variation;
|
76
84
|
return {
|
77
85
|
variationSku,
|
78
86
|
variationId,
|
@@ -86,7 +94,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
86
94
|
priceDiscounted,
|
87
95
|
inventoryProducts: [
|
88
96
|
{
|
89
|
-
qty:
|
97
|
+
qty: 1,
|
90
98
|
name: `${name} - ${variationSku}`,
|
91
99
|
sku: variationSku,
|
92
100
|
productVersions: [
|
@@ -96,7 +104,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
96
104
|
packageWidthMM: width,
|
97
105
|
packageHeightMM: height,
|
98
106
|
packageWeightGram: weight,
|
99
|
-
qty:
|
107
|
+
qty: stockReported
|
100
108
|
}
|
101
109
|
]
|
102
110
|
}
|
@@ -114,7 +122,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
114
122
|
channelCode: channels[i].channelCode,
|
115
123
|
channelCountry: shops[j].country_code,
|
116
124
|
categoryId,
|
117
|
-
productId:
|
125
|
+
productId: ((_a = parentLinks.find(e => e.children.includes(productId))) === null || _a === void 0 ? void 0 : _a.id) || productId,
|
118
126
|
name,
|
119
127
|
brand,
|
120
128
|
isVerified,
|
@@ -136,16 +144,26 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
136
144
|
childrenCategories: []
|
137
145
|
};
|
138
146
|
});
|
139
|
-
|
140
|
-
|
141
|
-
|
147
|
+
try {
|
148
|
+
mappedCategories = mappedCategories.map(category => {
|
149
|
+
if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {
|
150
|
+
category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId);
|
151
|
+
}
|
152
|
+
return category;
|
153
|
+
});
|
154
|
+
await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {
|
155
|
+
categories: mappedCategories
|
156
|
+
});
|
157
|
+
}
|
158
|
+
catch (e) { }
|
159
|
+
try {
|
160
|
+
for (let k = 0, l = mappedProducts.length; k < l; k++) {
|
161
|
+
await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, {
|
162
|
+
products: [mappedProducts[k]]
|
163
|
+
});
|
142
164
|
}
|
143
|
-
|
144
|
-
}
|
145
|
-
await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {
|
146
|
-
categories: mappedCategories
|
147
|
-
});
|
148
|
-
await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, { products: mappedProducts });
|
165
|
+
}
|
166
|
+
catch (e) { }
|
149
167
|
}
|
150
168
|
return true;
|
151
169
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marketplace-channel-product-mutation.js","sourceRoot":"","sources":["../../../server/service/marketplace-channel/marketplace-channel-product-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAsD;AACtD,qCAAuC;AAEvC
|
1
|
+
{"version":3,"file":"marketplace-channel-product-mutation.js","sourceRoot":"","sources":["../../../server/service/marketplace-channel/marketplace-channel-product-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAsD;AACtD,qCAAuC;AAEvC,6CAA4C;AAC5C,qFAAkE;AAElE,+GAAwG;AACxG,+DAA0D;AAG1D,IAAa,iCAAiC,GAA9C,MAAa,iCAAiC;IAE5C,KAAK,CAAC,iCAAiC,CAAQ,OAAY;;QACzD,MAAM,mCAAmC,GAAG,YAAM,CAAC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package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/integration-sellercraft",
|
3
|
-
"version": "4.2.
|
3
|
+
"version": "4.2.8",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -31,7 +31,7 @@
|
|
31
31
|
"@things-factory/context-ui": "^4.1.40",
|
32
32
|
"@things-factory/grist-ui": "^4.1.40",
|
33
33
|
"@things-factory/i18n-base": "^4.1.40",
|
34
|
-
"@things-factory/integration-marketplace": "^4.2.
|
34
|
+
"@things-factory/integration-marketplace": "^4.2.8",
|
35
35
|
"@things-factory/integration-ui": "^4.1.40",
|
36
36
|
"@things-factory/more-ui": "^4.1.40",
|
37
37
|
"@things-factory/resource-ui": "^4.1.40",
|
@@ -51,5 +51,5 @@
|
|
51
51
|
"nock": "^13.0.2",
|
52
52
|
"should": "^13.2.3"
|
53
53
|
},
|
54
|
-
"gitHead": "
|
54
|
+
"gitHead": "7ea97fd646fe004e409d3d3ff781cd5301e15140"
|
55
55
|
}
|
@@ -1,10 +1,25 @@
|
|
1
1
|
export const ORDER_STATUS = {
|
2
|
-
pending: '
|
3
|
-
processing: '
|
2
|
+
pending: 'CONFIRMED',
|
3
|
+
processing: 'CONFIRMED',
|
4
4
|
completed: 'DELIVERED',
|
5
5
|
cancelled: 'CANCELLED',
|
6
6
|
canceled: 'CANCELLED',
|
7
7
|
refunded: 'REFUND_COMPLETE',
|
8
8
|
failed: 'SHIPMENT_LOST_OR_DAMAGED',
|
9
|
-
refund: 'REFUND_COMPLETE'
|
9
|
+
refund: 'REFUND_COMPLETE',
|
10
|
+
ttk_100: 'PAYMENT_PENDING', // UNPAID
|
11
|
+
ttk_111: 'CONFIRMED', // AWAITING_SHIPMENT
|
12
|
+
ttk_112: 'READY_TO_SHIP', // AWAITING_COLLECTION
|
13
|
+
ttk_121: 'SHIPPED', // IN_TRANSIT
|
14
|
+
ttk_122: 'DELIVERED', // DELIVERED
|
15
|
+
ttk_130: 'CLOSED', // COMPLETED
|
16
|
+
ttk_140: 'CANCELLED', // CANCELLED
|
17
|
+
ttk_201: 'INITIATED_CANCELLATION', // CANCEL_PENDING
|
18
|
+
ttk_202: '', // CANCEL_REJECT
|
19
|
+
ttk_203: 'CANCELLED' // CANCEL_COMPLETED
|
20
|
+
}
|
21
|
+
|
22
|
+
export const SHIPPING_TYPE = {
|
23
|
+
DROP_SHIPPING: 'DROP_SHIPPING',
|
24
|
+
CROSS_DOCKING_PICKUP: 'CROSS_DOCKING_PICKUP'
|
10
25
|
}
|
package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.ts
CHANGED
@@ -38,10 +38,10 @@ export function ingestChannelOrderPackage() {
|
|
38
38
|
name: shipper_last_mile.name
|
39
39
|
}
|
40
40
|
|
41
|
-
|
41
|
+
let newOrderPackage: any = {
|
42
42
|
channel_shop_id,
|
43
43
|
native_order_id,
|
44
|
-
native_package_id,
|
44
|
+
native_package_id: native_package_id.toString(),
|
45
45
|
shipping_tracking_code,
|
46
46
|
shipping_type_value,
|
47
47
|
warehouse_code,
|
@@ -50,6 +50,10 @@ export function ingestChannelOrderPackage() {
|
|
50
50
|
shipper_last_mile,
|
51
51
|
order_item_ids
|
52
52
|
}
|
53
|
+
|
54
|
+
return {
|
55
|
+
payload: { ...newOrderPackage }
|
56
|
+
}
|
53
57
|
},
|
54
58
|
normalize(res) {
|
55
59
|
return res
|
@@ -13,7 +13,7 @@ export function ingestChannelOrder() {
|
|
13
13
|
return {
|
14
14
|
organisation_id: order.organisationId,
|
15
15
|
channel_shop_id: order.channelShopId,
|
16
|
-
native_order_id: order.id,
|
16
|
+
native_order_id: order.id.toString(),
|
17
17
|
ordered_at_date: new Date(order.createdAt).toISOString(),
|
18
18
|
ordered_at_time: new Date(order.createdAt).toISOString(),
|
19
19
|
updated_at_date: new Date(order.updatedAt).toISOString(),
|
@@ -58,7 +58,7 @@ export function ingestChannelOrder() {
|
|
58
58
|
ordered_at_time: new Date(order.createdAt).toISOString(),
|
59
59
|
updated_at_date: new Date(order.updatedAt).toISOString(),
|
60
60
|
updated_at_time: new Date(order.updatedAt).toISOString(),
|
61
|
-
sla_expires_at:
|
61
|
+
sla_expires_at: orderItem?.slaExpiresAt ? new Date(orderItem.slaExpiresAt).toISOString() : null,
|
62
62
|
charges: orderItem.charges.map(charge => {
|
63
63
|
return {
|
64
64
|
charge_type_value: charge.name,
|
@@ -31,7 +31,7 @@ export function ingestChannelProduct() {
|
|
31
31
|
inventory_products: variant?.inventoryProducts
|
32
32
|
? variant.inventoryProducts.map(inventoryProduct => {
|
33
33
|
return {
|
34
|
-
quantity: inventoryProduct.qty ||
|
34
|
+
quantity: inventoryProduct.qty || 0,
|
35
35
|
name: inventoryProduct.name,
|
36
36
|
inventory_sku: inventoryProduct.sku,
|
37
37
|
product_versions: inventoryProduct?.productVersions
|
@@ -45,7 +45,7 @@ export function ingestChannelProduct() {
|
|
45
45
|
package_weight_gram: productVersion?.packageWeightGram
|
46
46
|
? productVersion.packageWeightGram
|
47
47
|
: 0,
|
48
|
-
stock_available: productVersion.qty
|
48
|
+
stock_available: productVersion.qty
|
49
49
|
}
|
50
50
|
})
|
51
51
|
: []
|
@@ -65,22 +65,41 @@ export function ingestChannelProduct() {
|
|
65
65
|
label: product.name,
|
66
66
|
brand: product.brand || '',
|
67
67
|
is_verified: product.isVerified || true,
|
68
|
-
flexible_attributes: product.channelCode == 'WCM' ? true : false, // add channels that do not support category_attributes ingestion
|
69
|
-
images:
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
68
|
+
flexible_attributes: product.channelCode == 'WCM' || product.channelCode == 'MGT' ? true : false, // add channels that do not support category_attributes ingestion
|
69
|
+
images:
|
70
|
+
product?.images?.map(image => {
|
71
|
+
return {
|
72
|
+
file_url: image.url
|
73
|
+
}
|
74
|
+
}) || [],
|
75
|
+
product_attributes:
|
76
|
+
product?.attributes?.map(attribute => {
|
77
|
+
return {
|
78
|
+
...attribute,
|
79
|
+
native_attribute_id: attribute.native_attribute_id.toString()
|
80
|
+
}
|
81
|
+
}) || [],
|
82
|
+
variants: productVariations,
|
83
|
+
has_all_variants: product.channelCode == 'MGT' ? false : true
|
81
84
|
}
|
82
85
|
})
|
83
86
|
|
87
|
+
if (products[0].channelCode == 'MGT') {
|
88
|
+
let newList = []
|
89
|
+
for (let np of newProducts) {
|
90
|
+
if (np.native_product_id == np.variants[0].native_variant_id) {
|
91
|
+
let vars = newProducts
|
92
|
+
.filter(e => e.native_product_id == np.native_product_id)
|
93
|
+
.map(e => {
|
94
|
+
return e.variants[0]
|
95
|
+
})
|
96
|
+
np.variants = vars
|
97
|
+
newList.push(np)
|
98
|
+
}
|
99
|
+
}
|
100
|
+
newProducts = newList
|
101
|
+
}
|
102
|
+
|
84
103
|
return {
|
85
104
|
payload: [...newProducts]
|
86
105
|
}
|
package/server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts
CHANGED
@@ -44,9 +44,11 @@ export class SellercraftChannelIntegration {
|
|
44
44
|
})
|
45
45
|
|
46
46
|
if (response.ok) {
|
47
|
-
|
47
|
+
const result = await response.json()
|
48
|
+
return result
|
48
49
|
} else {
|
49
|
-
|
50
|
+
const result = await response.json()
|
51
|
+
throw new Error(`(${response.status}) ${result.message}`)
|
50
52
|
}
|
51
53
|
}
|
52
54
|
|
@@ -71,7 +73,8 @@ export class SellercraftChannelIntegration {
|
|
71
73
|
if (response.ok) {
|
72
74
|
return await response.json()
|
73
75
|
} else {
|
74
|
-
|
76
|
+
const result = await response.json()
|
77
|
+
throw new Error(`(${response.status}) ${result.message}`)
|
75
78
|
}
|
76
79
|
}
|
77
80
|
|
@@ -100,7 +103,8 @@ export class SellercraftChannelIntegration {
|
|
100
103
|
if (response.ok) {
|
101
104
|
return await response.json()
|
102
105
|
} else {
|
103
|
-
|
106
|
+
const result = await response.json()
|
107
|
+
throw new Error(`(${response.status}) ${result.message}`)
|
104
108
|
}
|
105
109
|
}
|
106
110
|
}
|
@@ -2,6 +2,7 @@ import Router from 'koa-router'
|
|
2
2
|
|
3
3
|
import { config } from '@things-factory/env'
|
4
4
|
import { StoreAPI } from '@things-factory/integration-marketplace'
|
5
|
+
|
5
6
|
import { PLATFORM } from '../constants'
|
6
7
|
|
7
8
|
const debug = require('debug')('things-factory:integration-sellercraft:sellercraft-router')
|
@@ -36,11 +37,12 @@ sellercraftRouter.post('/sellercraft/store/update-product-price', async (context
|
|
36
37
|
}
|
37
38
|
|
38
39
|
let mappedStore: any = {
|
39
|
-
accessKey: store.shop
|
40
|
-
accessSecret: store.shop
|
41
|
-
storeURL: store.shop
|
40
|
+
accessKey: store.shop?.credential?.consumer_key || '',
|
41
|
+
accessSecret: store.shop?.credential?.consumer_secret || '',
|
42
|
+
storeURL: store.shop?.credential?.store_url,
|
42
43
|
platform: PLATFORM[`${store.shop.org_prefix}`],
|
43
|
-
accessToken: store.shop
|
44
|
+
accessToken: store.shop?.credential?.access_token,
|
45
|
+
channelShopId: store.shop?.channel_shop_id
|
44
46
|
}
|
45
47
|
|
46
48
|
if (requestBody[i].native_variant_id != requestBody[i].native_product_id) {
|
@@ -95,11 +97,12 @@ sellercraftRouter.post('/sellercraft/store/update-product-stock', async (context
|
|
95
97
|
}
|
96
98
|
|
97
99
|
let mappedStore: any = {
|
98
|
-
accessKey: store.shop
|
99
|
-
accessSecret: store.shop
|
100
|
-
storeURL: store.shop
|
100
|
+
accessKey: store.shop?.credential?.consumer_key || '',
|
101
|
+
accessSecret: store.shop?.credential?.consumer_secret || '',
|
102
|
+
storeURL: store.shop?.credential?.store_url,
|
101
103
|
platform: PLATFORM[`${store.shop.org_prefix}`],
|
102
|
-
accessToken: store.shop
|
104
|
+
accessToken: store.shop?.credential?.access_token,
|
105
|
+
channelShopId: store.shop?.channel_shop_id
|
103
106
|
}
|
104
107
|
|
105
108
|
if (requestBody[i].native_variant_id != requestBody[i].native_product_id) {
|
@@ -152,18 +155,20 @@ sellercraftRouter.post('/sellercraft/store/update-order-status', async (context,
|
|
152
155
|
}
|
153
156
|
|
154
157
|
let mappedStore: any = {
|
155
|
-
accessKey: store.shop
|
156
|
-
accessSecret: store.shop
|
157
|
-
storeURL: store.shop
|
158
|
+
accessKey: store.shop?.credential?.consumer_key || '',
|
159
|
+
accessSecret: store.shop?.credential?.consumer_secret || '',
|
160
|
+
storeURL: store.shop?.credential?.store_url,
|
158
161
|
platform: PLATFORM[`${store.shop.org_prefix}`],
|
159
|
-
accessToken: store.shop
|
162
|
+
accessToken: store.shop?.credential?.access_token,
|
163
|
+
channelShopId: store.shop?.channel_shop_id
|
160
164
|
}
|
161
165
|
|
162
166
|
const reqBody = {
|
163
167
|
orderId: requestBody.native_order_id,
|
164
168
|
status: requestBody.order_status,
|
165
169
|
carrier: requestBody?.shipper_last_mile,
|
166
|
-
trackingNo: requestBody?.tracking_number
|
170
|
+
trackingNo: requestBody?.tracking_number,
|
171
|
+
orderItems: requestBody?.order_item_ids
|
167
172
|
}
|
168
173
|
|
169
174
|
result = await StoreAPI.updateOrderStatus(mappedStore, reqBody)
|
@@ -197,11 +202,12 @@ sellercraftRouter.post('/sellercraft/store/update-product-attribute', async (con
|
|
197
202
|
}
|
198
203
|
|
199
204
|
let mappedStore: any = {
|
200
|
-
accessKey: store.shop
|
201
|
-
accessSecret: store.shop
|
202
|
-
storeURL: store.shop
|
205
|
+
accessKey: store.shop?.credential?.consumer_key || '',
|
206
|
+
accessSecret: store.shop?.credential?.consumer_secret || '',
|
207
|
+
storeURL: store.shop?.credential?.store_url,
|
203
208
|
platform: PLATFORM[`${store.shop.org_prefix}`],
|
204
|
-
accessToken: store.shop
|
209
|
+
accessToken: store.shop?.credential?.access_token,
|
210
|
+
channelShopId: store.shop?.channel_shop_id
|
205
211
|
}
|
206
212
|
|
207
213
|
let { product_sku: productSku, native_product_id: itemId, variants } = requestBody
|