@things-factory/integration-marketplace 4.1.3 → 4.1.6
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/controllers/shopify/apis/get-store-order.js +153 -0
- package/dist-server/controllers/shopify/apis/get-store-order.js.map +1 -0
- package/dist-server/controllers/shopify/apis/index.js +3 -0
- package/dist-server/controllers/shopify/apis/index.js.map +1 -1
- package/dist-server/controllers/shopify/apis/set-store-order-status-ready-to-ship.js +32 -0
- package/dist-server/controllers/shopify/apis/set-store-order-status-ready-to-ship.js.map +1 -0
- package/dist-server/controllers/shopify/apis/update-order-status.js +24 -0
- package/dist-server/controllers/shopify/apis/update-order-status.js.map +1 -0
- package/dist-server/controllers/store-api/index.js +2 -2
- package/dist-server/controllers/store-api/index.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/get-store-order.js +55 -1
- package/dist-server/controllers/woocommerce/apis/get-store-order.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/index.js +2 -1
- package/dist-server/controllers/woocommerce/apis/index.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/set-store-order-status-ready-to-ship.js +20 -0
- package/dist-server/controllers/woocommerce/apis/set-store-order-status-ready-to-ship.js.map +1 -0
- package/dist-server/controllers/woocommerce/apis/{update-order.js → update-order-status.js} +5 -5
- package/dist-server/controllers/woocommerce/apis/update-order-status.js.map +1 -0
- package/package.json +15 -15
- package/server/controllers/shopify/apis/get-store-order.ts +172 -0
- package/server/controllers/shopify/apis/index.ts +3 -0
- package/server/controllers/shopify/apis/set-store-order-status-ready-to-ship.ts +30 -0
- package/server/controllers/shopify/apis/update-order-status.ts +20 -0
- package/server/controllers/store-api/index.ts +1 -1
- package/server/controllers/woocommerce/apis/get-store-order.ts +101 -2
- package/server/controllers/woocommerce/apis/index.ts +2 -1
- package/server/controllers/woocommerce/apis/set-store-order-status-ready-to-ship.ts +17 -0
- package/server/controllers/woocommerce/apis/{update-order.ts → update-order-status.ts} +2 -2
- package/dist-server/controllers/woocommerce/apis/update-order.js.map +0 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://shopify.dev/api/admin-rest/2022-01/resources/order#[get]/admin/api/2022-01/orders/{order_id}.json */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getStoreOrder = void 0;
|
|
5
|
+
function getStoreOrder() {
|
|
6
|
+
return {
|
|
7
|
+
method: 'get',
|
|
8
|
+
path: '/orders/{orderId}.json',
|
|
9
|
+
denormalize(req) {
|
|
10
|
+
const { orderId } = req;
|
|
11
|
+
return {
|
|
12
|
+
resource: {
|
|
13
|
+
orderId
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
normalize(res) {
|
|
18
|
+
var { order } = res;
|
|
19
|
+
const orderId = order.id;
|
|
20
|
+
const fulfillmentStatus = order.fulfillment_status;
|
|
21
|
+
let orderStatus = (order === null || order === void 0 ? void 0 : order.cancelled_at) ? 'cancelled' : fulfillmentStatus ? fulfillmentStatus : 'unfulfilled';
|
|
22
|
+
let itemCount = 0;
|
|
23
|
+
let result;
|
|
24
|
+
if (fulfillmentStatus != null) {
|
|
25
|
+
const fulfillment = order.fulfillments[0];
|
|
26
|
+
result = {
|
|
27
|
+
name: fulfillment.order_id,
|
|
28
|
+
orderNo: order.name,
|
|
29
|
+
currency: order.currency,
|
|
30
|
+
totalAmount: order.current_total_price,
|
|
31
|
+
remark: order.note,
|
|
32
|
+
orderCreatedAt: new Date(order.created_at).toUTCString(),
|
|
33
|
+
orderUpdatedAt: new Date(order.updated_at).toUTCString(),
|
|
34
|
+
discountValue: order.total_discounts,
|
|
35
|
+
status: orderStatus,
|
|
36
|
+
trackingNo: fulfillment.tracking_number,
|
|
37
|
+
shippingProvider: fulfillment.tracking_company,
|
|
38
|
+
recipientAddress: fulfillment.billing_address == null ? fulfillment.shipping_address : fulfillment.billing_address,
|
|
39
|
+
reason: order.cancel_reason,
|
|
40
|
+
orderItems: fulfillment.line_items.map(lineItem => {
|
|
41
|
+
return {
|
|
42
|
+
name: lineItem.id.toString(),
|
|
43
|
+
qty: lineItem.quantity,
|
|
44
|
+
status: lineItem.status || lineItem.fulfillment_status,
|
|
45
|
+
paidPrice: lineItem.price,
|
|
46
|
+
docRefNo: lineItem.id,
|
|
47
|
+
variationId: lineItem.product_exists === true ? lineItem.variant_id : lineItem.id.toString(),
|
|
48
|
+
variationSku: lineItem.sku,
|
|
49
|
+
channelSku: lineItem.sku,
|
|
50
|
+
variationName: lineItem.name
|
|
51
|
+
};
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
let lineItems = [];
|
|
57
|
+
const refundItems = order.refunds
|
|
58
|
+
.reduce((acc, curr) => {
|
|
59
|
+
const refundLineItems = curr.refund_line_items;
|
|
60
|
+
acc.push(...refundLineItems);
|
|
61
|
+
return acc;
|
|
62
|
+
}, [])
|
|
63
|
+
.reduce((acc, curr) => {
|
|
64
|
+
let sum = acc.findIndex(x => x.line_item_id === curr.line_item_id);
|
|
65
|
+
if (sum >= 0) {
|
|
66
|
+
acc[sum].quantity += curr.quantity;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
acc.push(curr);
|
|
70
|
+
}
|
|
71
|
+
return acc;
|
|
72
|
+
}, []);
|
|
73
|
+
let filteredLineItems = [];
|
|
74
|
+
if (orderStatus == 'cancelled') {
|
|
75
|
+
filteredLineItems = order.line_items;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
filteredLineItems = order.line_items.filter(item => item.fulfillable_quantity > 0);
|
|
79
|
+
}
|
|
80
|
+
filteredLineItems.map(lineItem => {
|
|
81
|
+
const matchedLineItem = refundItems.find(item => item.line_item_id == lineItem.id);
|
|
82
|
+
if (!matchedLineItem) {
|
|
83
|
+
lineItem = {
|
|
84
|
+
name: lineItem.id.toString(),
|
|
85
|
+
qty: lineItem.quantity,
|
|
86
|
+
paidPrice: lineItem.price,
|
|
87
|
+
docRefNo: lineItem.id,
|
|
88
|
+
variationId: lineItem.product_exists === true ? lineItem.variant_id : lineItem.id.toString(),
|
|
89
|
+
variationSku: lineItem.sku,
|
|
90
|
+
channelSku: lineItem.sku,
|
|
91
|
+
variationName: lineItem.name,
|
|
92
|
+
status: lineItem.status || lineItem.fulfillment_status
|
|
93
|
+
};
|
|
94
|
+
lineItems.push(lineItem);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
lineItem = {
|
|
98
|
+
name: lineItem.id.toString(),
|
|
99
|
+
qty: orderStatus == 'cancelled' ? lineItem.quantity : lineItem.quantity - matchedLineItem.quantity,
|
|
100
|
+
paidPrice: lineItem.price,
|
|
101
|
+
docRefNo: lineItem.id,
|
|
102
|
+
variationId: lineItem.product_exists === true ? lineItem.variant_id : lineItem.id.toString(),
|
|
103
|
+
variationSku: lineItem.sku,
|
|
104
|
+
channelSku: lineItem.sku,
|
|
105
|
+
variationName: lineItem.name,
|
|
106
|
+
status: lineItem.status || lineItem.fulfillment_status
|
|
107
|
+
};
|
|
108
|
+
if (lineItem.qty >= 0)
|
|
109
|
+
lineItems.push(lineItem);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
result = {
|
|
113
|
+
name: orderId,
|
|
114
|
+
orderNo: order.name,
|
|
115
|
+
currency: order.currency,
|
|
116
|
+
totalAmount: orderStatus == 'cancelled' ? order.total_price : order.current_total_price,
|
|
117
|
+
remark: order.note,
|
|
118
|
+
orderCreatedAt: new Date(order.created_at).toUTCString(),
|
|
119
|
+
orderUpdatedAt: new Date(order.updated_at).toUTCString(),
|
|
120
|
+
discountValue: order.total_discounts,
|
|
121
|
+
recipientAddress: order.billing_address,
|
|
122
|
+
status: orderStatus,
|
|
123
|
+
reason: order.cancel_reason,
|
|
124
|
+
orderItems: lineItems
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if ((order === null || order === void 0 ? void 0 : order.shipping_address) || (order === null || order === void 0 ? void 0 : order.billing_address)) {
|
|
128
|
+
const { address1, address2, phone, zip: postCode, city, country, first_name, last_name, province: state } = (order === null || order === void 0 ? void 0 : order.shipping_address) ? order.shipping_address : order.billing_address;
|
|
129
|
+
var orderShipping = {
|
|
130
|
+
address1,
|
|
131
|
+
address2,
|
|
132
|
+
address3: null,
|
|
133
|
+
address4: null,
|
|
134
|
+
address5: null,
|
|
135
|
+
phone1: phone,
|
|
136
|
+
phone2: null,
|
|
137
|
+
postCode,
|
|
138
|
+
city,
|
|
139
|
+
state,
|
|
140
|
+
country: country === 'MY' ? 'Malaysia' : country,
|
|
141
|
+
collectionCurrency: null,
|
|
142
|
+
attentionTo: `${first_name} ${last_name}`
|
|
143
|
+
};
|
|
144
|
+
result.orderShipping = orderShipping;
|
|
145
|
+
}
|
|
146
|
+
itemCount = result.orderItems.length;
|
|
147
|
+
result.itemCount = itemCount;
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
exports.getStoreOrder = getStoreOrder;
|
|
153
|
+
//# sourceMappingURL=get-store-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-store-order.js","sourceRoot":"","sources":["../../../../server/controllers/shopify/apis/get-store-order.ts"],"names":[],"mappings":";AAAA,+GAA+G;;;AAE/G,SAAgB,aAAa;IAC3B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,wBAAwB;QAC9B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAA;YAEvB,OAAO;gBACL,QAAQ,EAAE;oBACR,OAAO;iBACR;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,IAAI,EAAE,KAAK,EAAE,GAAG,GAAG,CAAA;YACnB,MAAM,OAAO,GAAG,KAAK,CAAC,EAAE,CAAA;YACxB,MAAM,iBAAiB,GAAG,KAAK,CAAC,kBAAkB,CAAA;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AI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe,CAAA,EAAE;gBACrD,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,GAAG,EAAE,QAAQ,EACb,IAAI,EACJ,OAAO,EACP,UAAU,EACV,SAAS,EACT,QAAQ,EAAE,KAAK,EAChB,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,gBAAgB,EAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,CAAA;gBAE5E,IAAI,aAAa,GAAG;oBAClB,QAAQ;oBACR,QAAQ;oBACR,QAAQ,EAAE,IAAI;oBACd,QAAQ,EAAE,IAAI;oBACd,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE,KAAK;oBACb,MAAM,EAAE,IAAI;oBACZ,QAAQ;oBACR,IAAI;oBACJ,KAAK;oBACL,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO;oBAChD,kBAAkB,EAAE,IAAI;oBACxB,WAAW,EAAE,GAAG,UAAU,IAAI,SAAS,EAAE;iBAC1C,CAAA;gBAED,MAAM,CAAC,aAAa,GAAG,aAAa,CAAA;aACrC;YAED,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAA;YACpC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAA;YAC5B,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC;AAzKD,sCAyKC"}
|
|
@@ -16,4 +16,7 @@ __exportStar(require("./get-store-products-count"), exports);
|
|
|
16
16
|
__exportStar(require("./get-store-orders"), exports);
|
|
17
17
|
__exportStar(require("./get-inventory-level"), exports);
|
|
18
18
|
__exportStar(require("./update-store-product-variation-stock"), exports);
|
|
19
|
+
__exportStar(require("./update-order-status"), exports);
|
|
20
|
+
__exportStar(require("./set-store-order-status-ready-to-ship"), exports);
|
|
21
|
+
__exportStar(require("./get-store-order"), exports);
|
|
19
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/shopify/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,uDAAoC;AACpC,6DAA0C;AAC1C,qDAAkC;AAClC,wDAAqC;AACrC,yEAAsD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/shopify/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,uDAAoC;AACpC,6DAA0C;AAC1C,qDAAkC;AAClC,wDAAqC;AACrC,yEAAsD;AACtD,wDAAqC;AACrC,yEAAsD;AACtD,oDAAiC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://shopify.dev/api/admin-rest/2021-10/resources/fulfillment#[post]/admin/api/2021-10/fulfillments.json */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.setStoreOrderStatusReadyToShip = void 0;
|
|
5
|
+
function setStoreOrderStatusReadyToShip() {
|
|
6
|
+
return {
|
|
7
|
+
method: 'post',
|
|
8
|
+
path: '/orders/{orderId}/fulfillments.json',
|
|
9
|
+
denormalize(req) {
|
|
10
|
+
const { orderId, trackingUrl, trackingNo, orderItemId, order } = req || {};
|
|
11
|
+
let locationId = JSON.parse(order.marketplaceOrderItems[0].marketplaceProductVariation.locationId)[0].location_id;
|
|
12
|
+
return {
|
|
13
|
+
payload: {
|
|
14
|
+
fulfillment: {
|
|
15
|
+
location_id: locationId,
|
|
16
|
+
tracking_number: trackingNo,
|
|
17
|
+
tracking_urls: [trackingUrl],
|
|
18
|
+
notify_customer: true
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
resource: {
|
|
22
|
+
orderId
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
normalize(res) {
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.setStoreOrderStatusReadyToShip = setStoreOrderStatusReadyToShip;
|
|
32
|
+
//# sourceMappingURL=set-store-order-status-ready-to-ship.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-store-order-status-ready-to-ship.js","sourceRoot":"","sources":["../../../../server/controllers/shopify/apis/set-store-order-status-ready-to-ship.ts"],"names":[],"mappings":";AAAA,iHAAiH;;;AAEjH,SAAgB,8BAA8B;IAC5C,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,qCAAqC;QAC3C,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAE1E,IAAI,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;YAEjH,OAAO;gBACL,OAAO,EAAE;oBACP,WAAW,EAAE;wBACX,WAAW,EAAE,UAAU;wBACvB,eAAe,EAAE,UAAU;wBAC3B,aAAa,EAAE,CAAC,WAAW,CAAC;wBAC5B,eAAe,EAAE,IAAI;qBACtB;iBACF;gBACD,QAAQ,EAAE;oBACR,OAAO;iBACR;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AA3BD,wEA2BC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://shopify.dev/api/admin-rest/2021-10/resources/fulfillment#[post]/admin/api/2021-10/orders/{order_id}/fulfillments/{fulfillment_id}/complete.json */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.updateOrderStatus = void 0;
|
|
5
|
+
function updateOrderStatus() {
|
|
6
|
+
return {
|
|
7
|
+
path: '/orders/{orderId}/fulfillments/{fulfillmentId}/complete.json',
|
|
8
|
+
method: 'post',
|
|
9
|
+
denormalize(req) {
|
|
10
|
+
const { orderId, fulfillmentId } = req;
|
|
11
|
+
return {
|
|
12
|
+
resource: {
|
|
13
|
+
orderId: orderId,
|
|
14
|
+
fulfillmentId: fulfillmentId.toString()
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
normalize(res) {
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.updateOrderStatus = updateOrderStatus;
|
|
24
|
+
//# sourceMappingURL=update-order-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-order-status.js","sourceRoot":"","sources":["../../../../server/controllers/shopify/apis/update-order-status.ts"],"names":[],"mappings":";AAAA,6JAA6J;;;AAE7J,SAAgB,iBAAiB;IAC/B,OAAO;QACL,IAAI,EAAE,8DAA8D;QACpE,MAAM,EAAE,MAAM;QACd,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,GAAG,CAAA;YACtC,OAAO;gBACL,QAAQ,EAAE;oBACR,OAAO,EAAE,OAAO;oBAChB,aAAa,EAAE,aAAa,CAAC,QAAQ,EAAE;iBACxC;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAjBD,8CAiBC"}
|
|
@@ -53,7 +53,7 @@ class StoreAPI {
|
|
|
53
53
|
static createStoreProduct(store, req) { }
|
|
54
54
|
static createStoreProductVariations(store, req) { }
|
|
55
55
|
static updateStoreProduct(store, req) { }
|
|
56
|
-
static
|
|
56
|
+
static updateOrderStatus(store, req) { }
|
|
57
57
|
static cancelStoreOrder(store, req) { }
|
|
58
58
|
static acceptStoreOrderCancellation(store, req) { }
|
|
59
59
|
static rejectStoreOrderCancellation(store, req) { }
|
|
@@ -190,7 +190,7 @@ __decorate([
|
|
|
190
190
|
__metadata("design:type", Function),
|
|
191
191
|
__metadata("design:paramtypes", [Object, Object]),
|
|
192
192
|
__metadata("design:returntype", Object)
|
|
193
|
-
], StoreAPI, "
|
|
193
|
+
], StoreAPI, "updateOrderStatus", null);
|
|
194
194
|
__decorate([
|
|
195
195
|
decorators_1.api,
|
|
196
196
|
__metadata("design:type", Function),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/store-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAuC;AAEvC,6CAAiD;AACjD,6CAAkC;AAElC,MAAa,QAAQ;IAGnB,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI;QACxC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG;YACzB,MAAM;YACN,IAAI;SACL,CAAA;IACH,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAI;QACrB,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACjC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE;QACjC,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,2BAAgB,CAAC,CAAA;QAClD,OAAO,MAAM,UAAU,CAAC,OAAO,CAAC;YAC9B,KAAK,EAAE,EAAE,EAAE,EAAE;YACb,SAAS,EAAE,CAAC,QAAQ,EAAE,yBAAyB,CAAC;SACjD,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,MAAM,EAAE,OAAQ;QAChD,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,2BAAgB,CAAC,CAAA;QAClD,OAAO,MAAM,UAAU,CAAC,IAAI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AAGjE;IADC,gBAAG;;;;uCACwC;AAG5C;IADC,gBAAG;;;;wCACyC;AAG7C;IADC,gBAAG;;;;uCACwC;AAG5C;IADC,gBAAG;;;;uCACwC;AAG5C;IADC,gBAAG;;;;gCAC4B;AAGhC;IADC,gBAAG;;;;mCACoC;AAGxC;IADC,gBAAG;;;;iCACkC;AAGtC;IADC,gBAAG;;;;mCACoC;AAGxC;IADC,gBAAG;;;;6CAC8C;AAGlD;IADC,gBAAG;;;;sDACuD;AAG3D;IADC,gBAAG;;;;uCACwC;AAG5C;IADC,gBAAG;;;;qCACsC;AAG1C;IADC,gBAAG;;;;wCACyC;AAG7C;IADC,gBAAG;;;;uCACwC;AAG5C;IADC,gBAAG;;;;qCACsC;AAG1C;IADC,gBAAG;;;;uCACwC;AAG5C;IADC,gBAAG;;;;gCACiC;AAGrC;IADC,gBAAG;;;;0CAC2C;AAG/C;IADC,gBAAG;;;;gDACiD;AAGrD;IADC,gBAAG;;;;iDACkD;AAGtD;IADC,gBAAG;;;;yDAC0D;AAG9D;IADC,gBAAG;;;;4CAC6C;AAGjD;IADC,gBAAG;;;;qDACsD;AAG1D;IADC,gBAAG;;;;sDACuD;AAG3D;IADC,gBAAG;;;;6CAC8C;AAGlD;IADC,gBAAG;;;;8CAC+C;AAlLrD,4BAmLC"}
|
|
@@ -13,7 +13,61 @@ function getStoreOrder() {
|
|
|
13
13
|
};
|
|
14
14
|
},
|
|
15
15
|
normalize(res) {
|
|
16
|
-
|
|
16
|
+
const order = res.items;
|
|
17
|
+
const { id: name, number: orderNo, currency, total: totalAmount, payment_method: paymentMethod, status, discount_total: discountValue, date_created_gmt, date_modified_gmt, shipping, billing, line_items } = order;
|
|
18
|
+
let docRefNo = orderNo;
|
|
19
|
+
var orderCreatedAt = new Date(date_created_gmt);
|
|
20
|
+
var orderUpdatedAt = new Date(date_modified_gmt);
|
|
21
|
+
let orderItems = line_items.map(item => {
|
|
22
|
+
var { id: name, product_id, variation_id, quantity: qty, price } = item;
|
|
23
|
+
return {
|
|
24
|
+
name,
|
|
25
|
+
variationId: variation_id === 0 ? product_id : variation_id,
|
|
26
|
+
qty,
|
|
27
|
+
paidPrice: price,
|
|
28
|
+
orderNo,
|
|
29
|
+
docRefNo,
|
|
30
|
+
paymentMethod,
|
|
31
|
+
discountValue
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
const { address_1: shippingAddress1, address_2: shippingAddress2, postcode: shippingPostCode, country: shippingCountry, city: shippingCity, first_name: shippingFirstName, last_name: shippingLastName, state: shippingState, phone: shippingPhone, email: shippingEmail } = shipping;
|
|
35
|
+
const { address_1: billingAddress1, address_2: billingAddress2, postcode: billingPostCode, country: billingCountry, city: billingCity, first_name: billingFirstName, last_name: billingLastName, state: billingState, phone: billingPhone, email: billingEmail } = billing;
|
|
36
|
+
var orderShipping = {
|
|
37
|
+
address1: shippingAddress1 == null ? billingAddress1 : shippingAddress1,
|
|
38
|
+
address2: shippingAddress2 == null ? billingAddress2 : shippingAddress2,
|
|
39
|
+
address3: null,
|
|
40
|
+
address4: null,
|
|
41
|
+
address5: null,
|
|
42
|
+
phone1: shippingPhone == null || shippingPhone == '' ? billingPhone : shippingPhone,
|
|
43
|
+
phone2: null,
|
|
44
|
+
email: shippingEmail == null ? billingEmail : shippingEmail,
|
|
45
|
+
postCode: shippingPostCode == null ? billingPostCode : shippingPostCode,
|
|
46
|
+
city: shippingCity == null ? billingCity : shippingCity,
|
|
47
|
+
state: shippingState == null ? billingState : shippingState,
|
|
48
|
+
country: shippingCountry == null
|
|
49
|
+
? billingCountry === 'MY'
|
|
50
|
+
? 'Malaysia'
|
|
51
|
+
: billingCountry
|
|
52
|
+
: billingCountry === 'MY'
|
|
53
|
+
? 'Malaysia'
|
|
54
|
+
: billingCountry,
|
|
55
|
+
collectionCurrency: currency,
|
|
56
|
+
attentionTo: shippingFirstName == null
|
|
57
|
+
? `${billingFirstName} ${billingLastName}`
|
|
58
|
+
: `${shippingFirstName} ${shippingLastName}`
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
name,
|
|
62
|
+
orderNo,
|
|
63
|
+
status,
|
|
64
|
+
orderCreatedAt,
|
|
65
|
+
orderUpdatedAt,
|
|
66
|
+
totalAmount,
|
|
67
|
+
itemCount: line_items.length,
|
|
68
|
+
orderItems,
|
|
69
|
+
orderShipping
|
|
70
|
+
};
|
|
17
71
|
}
|
|
18
72
|
};
|
|
19
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-store-order.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/get-store-order.ts"],"names":[],"mappings":";AAAA,2FAA2F;;;AAE3F,SAAgB,aAAa;IAC3B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAmB;QACzB,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,OAAO,EAAE,GAAG,GAAG,CAAA;YACrB,OAAO;
|
|
1
|
+
{"version":3,"file":"get-store-order.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/get-store-order.ts"],"names":[],"mappings":";AAAA,2FAA2F;;;AAE3F,SAAgB,aAAa;IAC3B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAmB;QACzB,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,OAAO,EAAE,GAAG,GAAG,CAAA;YACrB,OAAO;gBACL,QAAQ,EAAE,EAAE,OAAO,EAAE;aACtB,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAA;YAEvB,MAAM,EACJ,EAAE,EAAE,IAAI,EACR,MAAM,EAAE,OAAO,EACf,QAAQ,EACR,KAAK,EAAE,WAAW,EAClB,cAAc,EAAE,aAAa,EAC7B,MAAM,EACN,cAAc,EAAE,aAAa,EAC7B,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,UAAU,EACX,GAAG,KAAK,CAAA;YAET,IAAI,QA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V,aAAa;aACd,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AAjHD,sCAiHC"}
|
|
@@ -19,7 +19,7 @@ __exportStar(require("./get-store-orders"), exports);
|
|
|
19
19
|
__exportStar(require("./update-store-product-stock"), exports);
|
|
20
20
|
__exportStar(require("./update-store-product-variation-stock"), exports);
|
|
21
21
|
__exportStar(require("./get-store-product-categories"), exports);
|
|
22
|
-
__exportStar(require("./update-order"), exports);
|
|
22
|
+
__exportStar(require("./update-order-status"), exports);
|
|
23
23
|
__exportStar(require("./update-product-attribute"), exports);
|
|
24
24
|
__exportStar(require("./update-store-product-price"), exports);
|
|
25
25
|
__exportStar(require("./update-store-product-variation-price"), exports);
|
|
@@ -27,4 +27,5 @@ __exportStar(require("./get-store-order"), exports);
|
|
|
27
27
|
__exportStar(require("./update-store-product-price"), exports);
|
|
28
28
|
__exportStar(require("./update-store-product-variant-stock"), exports);
|
|
29
29
|
__exportStar(require("./update-store-product-variant-price"), exports);
|
|
30
|
+
__exportStar(require("./set-store-order-status-ready-to-ship"), exports);
|
|
30
31
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,sDAAmC;AACnC,iEAA8C;AAC9C,uDAAoC;AACpC,iEAA8C;AAC9C,qDAAkC;AAClC,+DAA4C;AAC5C,yEAAsD;AACtD,iEAA8C;AAC9C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,sDAAmC;AACnC,iEAA8C;AAC9C,uDAAoC;AACpC,iEAA8C;AAC9C,qDAAkC;AAClC,+DAA4C;AAC5C,yEAAsD;AACtD,iEAA8C;AAC9C,wDAAqC;AACrC,6DAA0C;AAC1C,+DAA4C;AAC5C,yEAAsD;AACtD,oDAAiC;AACjC,+DAA4C;AAC5C,uEAAoD;AACpD,uEAAoD;AACpD,yEAAsD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#create-an-order-note */
|
|
3
|
+
/* /wp-json/wc/v3/orders */
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.setStoreOrderStatusReadyToShip = void 0;
|
|
6
|
+
function setStoreOrderStatusReadyToShip(req) {
|
|
7
|
+
return {
|
|
8
|
+
method: 'post',
|
|
9
|
+
path: '/orders/{orderId}/notes',
|
|
10
|
+
denormalize(req) {
|
|
11
|
+
var { note, orderId } = req || {};
|
|
12
|
+
return { resource: { orderId: orderId }, payload: { note, customer_note: true } };
|
|
13
|
+
},
|
|
14
|
+
normalize(res) {
|
|
15
|
+
return res;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.setStoreOrderStatusReadyToShip = setStoreOrderStatusReadyToShip;
|
|
20
|
+
//# sourceMappingURL=set-store-order-status-ready-to-ship.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-store-order-status-ready-to-ship.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/set-store-order-status-ready-to-ship.ts"],"names":[],"mappings":";AAAA,8FAA8F;AAC9F,2BAA2B;;;AAE3B,SAAgB,8BAA8B,CAAC,GAAG;IAChD,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAEjC,OAAO,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,CAAA;QACnF,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAbD,wEAaC"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
/* https://woocommerce.github.io/woocommerce-rest-api-docs/#update-an-order */
|
|
3
3
|
/* /wp-json/wc/v3/orders/<id> */
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.
|
|
5
|
+
exports.updateOrderStatus = void 0;
|
|
6
6
|
const store_api_1 = require("../../store-api");
|
|
7
|
-
function
|
|
7
|
+
function updateOrderStatus(req) {
|
|
8
8
|
return {
|
|
9
9
|
method: 'put',
|
|
10
10
|
path: '/orders/{orderId}',
|
|
@@ -29,9 +29,9 @@ function updateOrder(req) {
|
|
|
29
29
|
return { resource: { orderId: orderId }, payload: { status: orderStatus } };
|
|
30
30
|
},
|
|
31
31
|
normalize(res) {
|
|
32
|
-
return res
|
|
32
|
+
return res;
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
exports.
|
|
37
|
-
//# sourceMappingURL=update-order.js.map
|
|
36
|
+
exports.updateOrderStatus = updateOrderStatus;
|
|
37
|
+
//# sourceMappingURL=update-order-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-order-status.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-order-status.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,gCAAgC;;;AAEhC,+CAA0C;AAE1C,SAAgB,iBAAiB,CAAC,GAAG;IACnC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAmB;QACzB,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC9B,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAEnC,MAAM,KAAK,GAAG,MAAM,oBAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;YAE9D,IAAI,WAAW,GAAG,MAAM,CAAA;YACxB,IAAI,WAAW,IAAI,QAAQ,EAAE;gBAC3B,IAAI,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE;oBAC7B,WAAW,GAAG,SAAS,CAAA;iBACxB;qBAAM;oBACL,WAAW,GAAG,KAAK,CAAC,MAAM,CAAA;iBAC3B;aACF;YACD,IAAI,WAAW,IAAI,eAAe,EAAE;gBAClC,WAAW,GAAG,WAAW,CAAA;aAC1B;YACD,IAAI,WAAW,IAAI,WAAW,EAAE;gBAC9B,WAAW,GAAG,WAAW,CAAA;aAC1B;YAED,OAAO,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,CAAA;QAC7E,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AA9BD,8CA8BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/integration-marketplace",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.6",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
"test": "DEBUG=things-factory:* NODE_ENV=development npx mocha -r ts-node/register ./test/**/*spec.ts"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@things-factory/apptool-ui": "^4.1.
|
|
29
|
-
"@things-factory/auth-ui": "^4.1.
|
|
30
|
-
"@things-factory/biz-base": "^4.1.
|
|
31
|
-
"@things-factory/code-ui": "^4.1.
|
|
32
|
-
"@things-factory/context-ui": "^4.1.
|
|
33
|
-
"@things-factory/grist-ui": "^4.1.
|
|
34
|
-
"@things-factory/i18n-base": "^4.1.
|
|
35
|
-
"@things-factory/integration-lmd": "^4.1.
|
|
36
|
-
"@things-factory/integration-ui": "^4.1.
|
|
37
|
-
"@things-factory/more-ui": "^4.1.
|
|
38
|
-
"@things-factory/resource-ui": "^4.1.
|
|
39
|
-
"@things-factory/setting-ui": "^4.1.
|
|
40
|
-
"@things-factory/system-ui": "^4.1.
|
|
28
|
+
"@things-factory/apptool-ui": "^4.1.6",
|
|
29
|
+
"@things-factory/auth-ui": "^4.1.6",
|
|
30
|
+
"@things-factory/biz-base": "^4.1.6",
|
|
31
|
+
"@things-factory/code-ui": "^4.1.6",
|
|
32
|
+
"@things-factory/context-ui": "^4.1.6",
|
|
33
|
+
"@things-factory/grist-ui": "^4.1.6",
|
|
34
|
+
"@things-factory/i18n-base": "^4.1.6",
|
|
35
|
+
"@things-factory/integration-lmd": "^4.1.6",
|
|
36
|
+
"@things-factory/integration-ui": "^4.1.6",
|
|
37
|
+
"@things-factory/more-ui": "^4.1.6",
|
|
38
|
+
"@things-factory/resource-ui": "^4.1.6",
|
|
39
|
+
"@things-factory/setting-ui": "^4.1.6",
|
|
40
|
+
"@things-factory/system-ui": "^4.1.6",
|
|
41
41
|
"debug": "^4.1.1",
|
|
42
42
|
"node-fetch": "^2.6.0",
|
|
43
43
|
"querystring": "^0.2.1"
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"nock": "^13.0.2",
|
|
53
53
|
"should": "^13.2.3"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "3b0bbe1cd54f9585579fb85c64cce3338b45fa30"
|
|
56
56
|
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/* https://shopify.dev/api/admin-rest/2022-01/resources/order#[get]/admin/api/2022-01/orders/{order_id}.json */
|
|
2
|
+
|
|
3
|
+
export function getStoreOrder() {
|
|
4
|
+
return {
|
|
5
|
+
method: 'get',
|
|
6
|
+
path: '/orders/{orderId}.json',
|
|
7
|
+
denormalize(req) {
|
|
8
|
+
const { orderId } = req
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
resource: {
|
|
12
|
+
orderId
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
normalize(res) {
|
|
17
|
+
var { order } = res
|
|
18
|
+
const orderId = order.id
|
|
19
|
+
const fulfillmentStatus = order.fulfillment_status
|
|
20
|
+
let orderStatus = order?.cancelled_at ? 'cancelled' : fulfillmentStatus ? fulfillmentStatus : 'unfulfilled'
|
|
21
|
+
|
|
22
|
+
let itemCount: Number = 0
|
|
23
|
+
let result: any
|
|
24
|
+
|
|
25
|
+
if (fulfillmentStatus != null) {
|
|
26
|
+
const fulfillment = order.fulfillments[0]
|
|
27
|
+
|
|
28
|
+
result = {
|
|
29
|
+
name: fulfillment.order_id,
|
|
30
|
+
orderNo: order.name,
|
|
31
|
+
currency: order.currency,
|
|
32
|
+
totalAmount: order.current_total_price,
|
|
33
|
+
remark: order.note,
|
|
34
|
+
orderCreatedAt: new Date(order.created_at).toUTCString(),
|
|
35
|
+
orderUpdatedAt: new Date(order.updated_at).toUTCString(),
|
|
36
|
+
discountValue: order.total_discounts,
|
|
37
|
+
status: orderStatus,
|
|
38
|
+
trackingNo: fulfillment.tracking_number,
|
|
39
|
+
shippingProvider: fulfillment.tracking_company,
|
|
40
|
+
recipientAddress:
|
|
41
|
+
fulfillment.billing_address == null ? fulfillment.shipping_address : fulfillment.billing_address,
|
|
42
|
+
reason: order.cancel_reason,
|
|
43
|
+
orderItems: fulfillment.line_items.map(lineItem => {
|
|
44
|
+
return {
|
|
45
|
+
name: lineItem.id.toString(),
|
|
46
|
+
qty: lineItem.quantity,
|
|
47
|
+
status: lineItem.status || lineItem.fulfillment_status,
|
|
48
|
+
paidPrice: lineItem.price,
|
|
49
|
+
docRefNo: lineItem.id,
|
|
50
|
+
variationId: lineItem.product_exists === true ? lineItem.variant_id : lineItem.id.toString(),
|
|
51
|
+
variationSku: lineItem.sku,
|
|
52
|
+
channelSku: lineItem.sku,
|
|
53
|
+
variationName: lineItem.name
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
let lineItems = []
|
|
59
|
+
|
|
60
|
+
const refundItems = order.refunds
|
|
61
|
+
.reduce((acc, curr) => {
|
|
62
|
+
const refundLineItems = curr.refund_line_items
|
|
63
|
+
acc.push(...refundLineItems)
|
|
64
|
+
|
|
65
|
+
return acc
|
|
66
|
+
}, [])
|
|
67
|
+
.reduce((acc, curr) => {
|
|
68
|
+
let sum = acc.findIndex(x => x.line_item_id === curr.line_item_id)
|
|
69
|
+
if (sum >= 0) {
|
|
70
|
+
acc[sum].quantity += curr.quantity
|
|
71
|
+
} else {
|
|
72
|
+
acc.push(curr)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return acc
|
|
76
|
+
}, [])
|
|
77
|
+
|
|
78
|
+
let filteredLineItems = []
|
|
79
|
+
if (orderStatus == 'cancelled') {
|
|
80
|
+
filteredLineItems = order.line_items
|
|
81
|
+
} else {
|
|
82
|
+
filteredLineItems = order.line_items.filter(item => item.fulfillable_quantity > 0)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
filteredLineItems.map(lineItem => {
|
|
86
|
+
const matchedLineItem = refundItems.find(item => item.line_item_id == lineItem.id)
|
|
87
|
+
|
|
88
|
+
if (!matchedLineItem) {
|
|
89
|
+
lineItem = {
|
|
90
|
+
name: lineItem.id.toString(),
|
|
91
|
+
qty: lineItem.quantity,
|
|
92
|
+
paidPrice: lineItem.price,
|
|
93
|
+
docRefNo: lineItem.id,
|
|
94
|
+
variationId: lineItem.product_exists === true ? lineItem.variant_id : lineItem.id.toString(),
|
|
95
|
+
variationSku: lineItem.sku,
|
|
96
|
+
channelSku: lineItem.sku,
|
|
97
|
+
variationName: lineItem.name,
|
|
98
|
+
status: lineItem.status || lineItem.fulfillment_status
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
lineItems.push(lineItem)
|
|
102
|
+
} else {
|
|
103
|
+
lineItem = {
|
|
104
|
+
name: lineItem.id.toString(),
|
|
105
|
+
qty: orderStatus == 'cancelled' ? lineItem.quantity : lineItem.quantity - matchedLineItem.quantity,
|
|
106
|
+
paidPrice: lineItem.price,
|
|
107
|
+
docRefNo: lineItem.id,
|
|
108
|
+
variationId: lineItem.product_exists === true ? lineItem.variant_id : lineItem.id.toString(),
|
|
109
|
+
variationSku: lineItem.sku,
|
|
110
|
+
channelSku: lineItem.sku,
|
|
111
|
+
variationName: lineItem.name,
|
|
112
|
+
status: lineItem.status || lineItem.fulfillment_status
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (lineItem.qty >= 0) lineItems.push(lineItem)
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
result = {
|
|
120
|
+
name: orderId,
|
|
121
|
+
orderNo: order.name,
|
|
122
|
+
currency: order.currency,
|
|
123
|
+
totalAmount: orderStatus == 'cancelled' ? order.total_price : order.current_total_price,
|
|
124
|
+
remark: order.note,
|
|
125
|
+
orderCreatedAt: new Date(order.created_at).toUTCString(),
|
|
126
|
+
orderUpdatedAt: new Date(order.updated_at).toUTCString(),
|
|
127
|
+
discountValue: order.total_discounts,
|
|
128
|
+
recipientAddress: order.billing_address,
|
|
129
|
+
status: orderStatus,
|
|
130
|
+
reason: order.cancel_reason,
|
|
131
|
+
orderItems: lineItems
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (order?.shipping_address || order?.billing_address) {
|
|
136
|
+
const {
|
|
137
|
+
address1,
|
|
138
|
+
address2,
|
|
139
|
+
phone,
|
|
140
|
+
zip: postCode,
|
|
141
|
+
city,
|
|
142
|
+
country,
|
|
143
|
+
first_name,
|
|
144
|
+
last_name,
|
|
145
|
+
province: state
|
|
146
|
+
} = order?.shipping_address ? order.shipping_address : order.billing_address
|
|
147
|
+
|
|
148
|
+
var orderShipping = {
|
|
149
|
+
address1,
|
|
150
|
+
address2,
|
|
151
|
+
address3: null,
|
|
152
|
+
address4: null,
|
|
153
|
+
address5: null,
|
|
154
|
+
phone1: phone,
|
|
155
|
+
phone2: null,
|
|
156
|
+
postCode,
|
|
157
|
+
city,
|
|
158
|
+
state,
|
|
159
|
+
country: country === 'MY' ? 'Malaysia' : country,
|
|
160
|
+
collectionCurrency: null,
|
|
161
|
+
attentionTo: `${first_name} ${last_name}`
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
result.orderShipping = orderShipping
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
itemCount = result.orderItems.length
|
|
168
|
+
result.itemCount = itemCount
|
|
169
|
+
return result
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -4,3 +4,6 @@ export * from './get-store-products-count'
|
|
|
4
4
|
export * from './get-store-orders'
|
|
5
5
|
export * from './get-inventory-level'
|
|
6
6
|
export * from './update-store-product-variation-stock'
|
|
7
|
+
export * from './update-order-status'
|
|
8
|
+
export * from './set-store-order-status-ready-to-ship'
|
|
9
|
+
export * from './get-store-order'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* https://shopify.dev/api/admin-rest/2021-10/resources/fulfillment#[post]/admin/api/2021-10/fulfillments.json */
|
|
2
|
+
|
|
3
|
+
export function setStoreOrderStatusReadyToShip() {
|
|
4
|
+
return {
|
|
5
|
+
method: 'post',
|
|
6
|
+
path: '/orders/{orderId}/fulfillments.json',
|
|
7
|
+
denormalize(req) {
|
|
8
|
+
const { orderId, trackingUrl, trackingNo, orderItemId, order } = req || {}
|
|
9
|
+
|
|
10
|
+
let locationId = JSON.parse(order.marketplaceOrderItems[0].marketplaceProductVariation.locationId)[0].location_id
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
payload: {
|
|
14
|
+
fulfillment: {
|
|
15
|
+
location_id: locationId,
|
|
16
|
+
tracking_number: trackingNo,
|
|
17
|
+
tracking_urls: [trackingUrl],
|
|
18
|
+
notify_customer: true
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
resource: {
|
|
22
|
+
orderId
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
normalize(res) {
|
|
27
|
+
return res
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* https://shopify.dev/api/admin-rest/2021-10/resources/fulfillment#[post]/admin/api/2021-10/orders/{order_id}/fulfillments/{fulfillment_id}/complete.json */
|
|
2
|
+
|
|
3
|
+
export function updateOrderStatus() {
|
|
4
|
+
return {
|
|
5
|
+
path: '/orders/{orderId}/fulfillments/{fulfillmentId}/complete.json',
|
|
6
|
+
method: 'post',
|
|
7
|
+
denormalize(req) {
|
|
8
|
+
const { orderId, fulfillmentId } = req
|
|
9
|
+
return {
|
|
10
|
+
resource: {
|
|
11
|
+
orderId: orderId,
|
|
12
|
+
fulfillmentId: fulfillmentId.toString()
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
normalize(res) {
|
|
17
|
+
return res
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -7,11 +7,110 @@ export function getStoreOrder() {
|
|
|
7
7
|
denormalize(req) {
|
|
8
8
|
var { orderId } = req
|
|
9
9
|
return {
|
|
10
|
-
|
|
10
|
+
resource: { orderId }
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
normalize(res) {
|
|
14
|
-
|
|
14
|
+
const order = res.items
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
id: name,
|
|
18
|
+
number: orderNo,
|
|
19
|
+
currency,
|
|
20
|
+
total: totalAmount,
|
|
21
|
+
payment_method: paymentMethod,
|
|
22
|
+
status,
|
|
23
|
+
discount_total: discountValue,
|
|
24
|
+
date_created_gmt,
|
|
25
|
+
date_modified_gmt,
|
|
26
|
+
shipping,
|
|
27
|
+
billing,
|
|
28
|
+
line_items
|
|
29
|
+
} = order
|
|
30
|
+
|
|
31
|
+
let docRefNo = orderNo
|
|
32
|
+
var orderCreatedAt = new Date(date_created_gmt)
|
|
33
|
+
var orderUpdatedAt = new Date(date_modified_gmt)
|
|
34
|
+
|
|
35
|
+
let orderItems = line_items.map(item => {
|
|
36
|
+
var { id: name, product_id, variation_id, quantity: qty, price } = item
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
name,
|
|
40
|
+
variationId: variation_id === 0 ? product_id : variation_id,
|
|
41
|
+
qty,
|
|
42
|
+
paidPrice: price,
|
|
43
|
+
orderNo,
|
|
44
|
+
docRefNo,
|
|
45
|
+
paymentMethod,
|
|
46
|
+
discountValue
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const {
|
|
51
|
+
address_1: shippingAddress1,
|
|
52
|
+
address_2: shippingAddress2,
|
|
53
|
+
postcode: shippingPostCode,
|
|
54
|
+
country: shippingCountry,
|
|
55
|
+
city: shippingCity,
|
|
56
|
+
first_name: shippingFirstName,
|
|
57
|
+
last_name: shippingLastName,
|
|
58
|
+
state: shippingState,
|
|
59
|
+
phone: shippingPhone,
|
|
60
|
+
email: shippingEmail
|
|
61
|
+
} = shipping
|
|
62
|
+
|
|
63
|
+
const {
|
|
64
|
+
address_1: billingAddress1,
|
|
65
|
+
address_2: billingAddress2,
|
|
66
|
+
postcode: billingPostCode,
|
|
67
|
+
country: billingCountry,
|
|
68
|
+
city: billingCity,
|
|
69
|
+
first_name: billingFirstName,
|
|
70
|
+
last_name: billingLastName,
|
|
71
|
+
state: billingState,
|
|
72
|
+
phone: billingPhone,
|
|
73
|
+
email: billingEmail
|
|
74
|
+
} = billing
|
|
75
|
+
|
|
76
|
+
var orderShipping = {
|
|
77
|
+
address1: shippingAddress1 == null ? billingAddress1 : shippingAddress1,
|
|
78
|
+
address2: shippingAddress2 == null ? billingAddress2 : shippingAddress2,
|
|
79
|
+
address3: null,
|
|
80
|
+
address4: null,
|
|
81
|
+
address5: null,
|
|
82
|
+
phone1: shippingPhone == null || shippingPhone == '' ? billingPhone : shippingPhone,
|
|
83
|
+
phone2: null,
|
|
84
|
+
email: shippingEmail == null ? billingEmail : shippingEmail,
|
|
85
|
+
postCode: shippingPostCode == null ? billingPostCode : shippingPostCode,
|
|
86
|
+
city: shippingCity == null ? billingCity : shippingCity,
|
|
87
|
+
state: shippingState == null ? billingState : shippingState,
|
|
88
|
+
country:
|
|
89
|
+
shippingCountry == null
|
|
90
|
+
? billingCountry === 'MY'
|
|
91
|
+
? 'Malaysia'
|
|
92
|
+
: billingCountry
|
|
93
|
+
: billingCountry === 'MY'
|
|
94
|
+
? 'Malaysia'
|
|
95
|
+
: billingCountry,
|
|
96
|
+
collectionCurrency: currency,
|
|
97
|
+
attentionTo:
|
|
98
|
+
shippingFirstName == null
|
|
99
|
+
? `${billingFirstName} ${billingLastName}`
|
|
100
|
+
: `${shippingFirstName} ${shippingLastName}`
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
name,
|
|
105
|
+
orderNo,
|
|
106
|
+
status,
|
|
107
|
+
orderCreatedAt,
|
|
108
|
+
orderUpdatedAt,
|
|
109
|
+
totalAmount,
|
|
110
|
+
itemCount: line_items.length,
|
|
111
|
+
orderItems,
|
|
112
|
+
orderShipping
|
|
113
|
+
}
|
|
15
114
|
}
|
|
16
115
|
}
|
|
17
116
|
}
|
|
@@ -7,7 +7,7 @@ export * from './get-store-orders'
|
|
|
7
7
|
export * from './update-store-product-stock'
|
|
8
8
|
export * from './update-store-product-variation-stock'
|
|
9
9
|
export * from './get-store-product-categories'
|
|
10
|
-
export * from './update-order'
|
|
10
|
+
export * from './update-order-status'
|
|
11
11
|
export * from './update-product-attribute'
|
|
12
12
|
export * from './update-store-product-price'
|
|
13
13
|
export * from './update-store-product-variation-price'
|
|
@@ -15,3 +15,4 @@ export * from './get-store-order'
|
|
|
15
15
|
export * from './update-store-product-price'
|
|
16
16
|
export * from './update-store-product-variant-stock'
|
|
17
17
|
export * from './update-store-product-variant-price'
|
|
18
|
+
export * from './set-store-order-status-ready-to-ship'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#create-an-order-note */
|
|
2
|
+
/* /wp-json/wc/v3/orders */
|
|
3
|
+
|
|
4
|
+
export function setStoreOrderStatusReadyToShip(req) {
|
|
5
|
+
return {
|
|
6
|
+
method: 'post',
|
|
7
|
+
path: '/orders/{orderId}/notes',
|
|
8
|
+
denormalize(req) {
|
|
9
|
+
var { note, orderId } = req || {}
|
|
10
|
+
|
|
11
|
+
return { resource: { orderId: orderId }, payload: { note, customer_note: true } }
|
|
12
|
+
},
|
|
13
|
+
normalize(res) {
|
|
14
|
+
return res
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { StoreAPI } from '../../store-api'
|
|
5
5
|
|
|
6
|
-
export function
|
|
6
|
+
export function updateOrderStatus(req) {
|
|
7
7
|
return {
|
|
8
8
|
method: 'put',
|
|
9
9
|
path: '/orders/{orderId}',
|
|
@@ -30,7 +30,7 @@ export function updateOrder(req) {
|
|
|
30
30
|
return { resource: { orderId: orderId }, payload: { status: orderStatus } }
|
|
31
31
|
},
|
|
32
32
|
normalize(res) {
|
|
33
|
-
return res
|
|
33
|
+
return res
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-order.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-order.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,gCAAgC;;;AAEhC,+CAA0C;AAE1C,SAAgB,WAAW,CAAC,GAAG;IAC7B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAmB;QACzB,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC9B,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAEnC,MAAM,KAAK,GAAG,MAAM,oBAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;YAE9D,IAAI,WAAW,GAAG,MAAM,CAAA;YACxB,IAAI,WAAW,IAAI,QAAQ,EAAE;gBAC3B,IAAI,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE;oBAC7B,WAAW,GAAG,SAAS,CAAA;iBACxB;qBAAM;oBACL,WAAW,GAAG,KAAK,CAAC,MAAM,CAAA;iBAC3B;aACF;YACD,IAAI,WAAW,IAAI,eAAe,EAAE;gBAClC,WAAW,GAAG,WAAW,CAAA;aAC1B;YACD,IAAI,WAAW,IAAI,WAAW,EAAE;gBAC9B,WAAW,GAAG,WAAW,CAAA;aAC1B;YAED,OAAO,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,CAAA;QAC7E,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAC,KAAK,CAAA;QAClB,CAAC;KACF,CAAA;AACH,CAAC;AA9BD,kCA8BC"}
|