@porulle/adapter-woocommerce 0.65.1 → 0.67.0
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/index.js +14 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/index.ts +14 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@porulle/adapter-woocommerce",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.67.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"node": ">=20.19.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@porulle/core": "0.
|
|
18
|
+
"@porulle/core": "0.67.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^24.5.2",
|
package/src/index.ts
CHANGED
|
@@ -838,8 +838,20 @@ export function wooConnector(options: WooConnectorOptions = {}): ChannelConnecto
|
|
|
838
838
|
if (!auth) return Err({ code: "WOO_CREDENTIALS_REQUIRED", message: "WooCommerce consumerKey and consumerSecret are required.", retriable: false });
|
|
839
839
|
const url = buildWooUrl(store.storeDomain, "/wp-json/wc/v3/orders", auth.key, auth.secret, 1);
|
|
840
840
|
const [firstName, ...lastParts] = slice.customer.name.trim().split(/\s+/);
|
|
841
|
-
const
|
|
842
|
-
|
|
841
|
+
const source = slice.customer.shippingAddress;
|
|
842
|
+
// WooCommerce's order address spelling (REST v3 `shipping`/`billing`).
|
|
843
|
+
const address = {
|
|
844
|
+
first_name: source.firstName,
|
|
845
|
+
last_name: source.lastName,
|
|
846
|
+
address_1: source.line1,
|
|
847
|
+
...(source.line2 ? { address_2: source.line2 } : {}),
|
|
848
|
+
city: source.city,
|
|
849
|
+
...(source.region ? { state: source.region } : {}),
|
|
850
|
+
...(source.postalCode ? { postcode: source.postalCode } : {}),
|
|
851
|
+
country: source.countryCode,
|
|
852
|
+
...(source.phone ? { phone: source.phone } : {}),
|
|
853
|
+
};
|
|
854
|
+
const billing = { ...address, first_name: firstName ?? source.firstName, last_name: lastParts.join(" ") || source.lastName, email: slice.customer.email };
|
|
843
855
|
const result = await request<{ id: number | string }>(fetchImpl, url, {
|
|
844
856
|
method: "POST",
|
|
845
857
|
headers: { "content-type": "application/json", "idempotency-key": `porulle:${slice.orderId}` },
|