@porulle/adapter-woocommerce 0.65.1 → 0.66.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 CHANGED
@@ -693,8 +693,20 @@ export function wooConnector(options = {}) {
693
693
  return Err({ code: "WOO_CREDENTIALS_REQUIRED", message: "WooCommerce consumerKey and consumerSecret are required.", retriable: false });
694
694
  const url = buildWooUrl(store.storeDomain, "/wp-json/wc/v3/orders", auth.key, auth.secret, 1);
695
695
  const [firstName, ...lastParts] = slice.customer.name.trim().split(/\s+/);
696
- const address = slice.customer.shippingAddress;
697
- const billing = { first_name: firstName ?? "", last_name: lastParts.join(" "), email: slice.customer.email, ...address };
696
+ const source = slice.customer.shippingAddress;
697
+ // WooCommerce's order address spelling (REST v3 `shipping`/`billing`).
698
+ const address = {
699
+ first_name: source.firstName,
700
+ last_name: source.lastName,
701
+ address_1: source.line1,
702
+ ...(source.line2 ? { address_2: source.line2 } : {}),
703
+ city: source.city,
704
+ ...(source.region ? { state: source.region } : {}),
705
+ ...(source.postalCode ? { postcode: source.postalCode } : {}),
706
+ country: source.countryCode,
707
+ ...(source.phone ? { phone: source.phone } : {}),
708
+ };
709
+ const billing = { ...address, first_name: firstName ?? source.firstName, last_name: lastParts.join(" ") || source.lastName, email: slice.customer.email };
698
710
  const result = await request(fetchImpl, url, {
699
711
  method: "POST",
700
712
  headers: { "content-type": "application/json", "idempotency-key": `porulle:${slice.orderId}` },