@kizlo/woocommerce 0.15.0 → 0.17.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/README.md +46 -3
- package/dist/index.d.ts +1849 -2115
- package/dist/index.js +40 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,23 +42,66 @@ pnpm add @kizlo/woocommerce
|
|
|
42
42
|
|
|
43
43
|
See the [docs](https://kizlo.io/docs) for setup and usage.
|
|
44
44
|
|
|
45
|
+
## Read cart separately from checkout
|
|
46
|
+
|
|
47
|
+
Checkout get, update, confirm, and retry responses no longer include `cart`. Replace reads of `checkout.cart` with `cart.get`, or use the cart returned by a cart mutation:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const checkout = await kizlo.woocommerce.checkout.get.call()
|
|
51
|
+
const cart = await kizlo.woocommerce.cart.get.call()
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Refresh cart separately after checkout changes when your UI needs current totals or items. Checkout conflict errors still carry `data.cart` evidence; see [reviewed total protection](#protect-a-reviewed-checkout-total). Update consumers before deploying the companion plugin update.
|
|
55
|
+
|
|
56
|
+
## Require login for checkout
|
|
57
|
+
|
|
58
|
+
Set `allowGuest: false` to require a session from your configured Kizlo auth adapter for `checkout.get`, `checkout.update`, `checkout.confirm`, and `checkout.retry`. Anonymous calls return `UNAUTHORIZED` (401) before changing guest cookies or contacting WooCommerce. Register the integration alongside your auth integration in `createKizlo`; commerce hooks need no auth-provider client state.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { woocommerce } from "@kizlo/woocommerce"
|
|
62
|
+
|
|
63
|
+
const commerce = woocommerce({ allowGuest: false })
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`allowGuest` defaults to `true`, permitting logged-out checkout subject to WooCommerce's own guest-checkout settings and validation. Customer APIs such as `customers.get` always require login. Guest carts, product/storefront reads, and order ownership/key checks (including guest receipts) keep their existing behavior. After installing a release containing this option, replace your application checkout-auth wrapper with `woocommerce({ allowGuest: false })`; procedure inputs, outputs, and hooks stay the same.
|
|
67
|
+
|
|
68
|
+
## Submit partial checkout addresses
|
|
69
|
+
|
|
70
|
+
Confirm and retry accept optional core address fields, including billing email. Send only the fields you collect. The billing address object is required; shipping is optional. Each supplied address must include `additionalFields`, with any registered required answers (or `{}` when none are required).
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
const billingAddress = {
|
|
74
|
+
firstName: "Ada", lastName: "Lovelace",
|
|
75
|
+
address1: "1 Store Street", city: "London", postcode: "SW1A 1AA", country: "GB",
|
|
76
|
+
email: "ada@example.com", additionalFields: {},
|
|
77
|
+
}
|
|
78
|
+
await kizlo.woocommerce.checkout.confirm.call({ body: { billingAddress, paymentMethod: "bacs" } })
|
|
79
|
+
// For an existing unpaid order:
|
|
80
|
+
await kizlo.woocommerce.checkout.retry.call({
|
|
81
|
+
params: { orderId },
|
|
82
|
+
body: { key: orderKey, billingAddress, paymentMethod: "bacs" },
|
|
83
|
+
})
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Omitted fields produce no wire keys; explicit empty strings request clearing where WooCommerce permits it. WooCommerce validates the resulting address against its live rules through the existing checkout errors. Full-address callers remain valid. See [Billing Tax IDs](#billing-tax-ids) for Tax ID omission and [additional checkout fields](https://kizlo.io/docs/concepts/additional-checkout-fields) for registered answer contracts and native billing-to-shipping mirroring.
|
|
87
|
+
|
|
45
88
|
## Billing Tax IDs
|
|
46
89
|
|
|
47
90
|
Billing addresses expose `taxId` on customers, carts, checkout responses, and orders. The field is always a string on output and defaults to `""` when it has not been set. Billing address inputs accept an optional `taxId`; shipping addresses have no native `taxId`, and Kizlo discards managed shipping copies independently of the hidden UI rule.
|
|
48
91
|
|
|
49
92
|
```ts
|
|
50
|
-
await kizlo.woocommerce.cart.
|
|
93
|
+
await kizlo.woocommerce.cart.updateAddress.call({
|
|
51
94
|
body: { billingAddress: { taxId: "GB123456789" } },
|
|
52
95
|
})
|
|
53
96
|
```
|
|
54
97
|
|
|
55
98
|
Store administrators can make the field mandatory from **WooCommerce → Settings → Accounts & Privacy → Checkout → Require Tax ID at checkout**. It remains optional by default.
|
|
56
99
|
|
|
57
|
-
The native value maps to the official registered `kizlo/tax-id` address field. For example, `{ billingAddress: { taxId: "GB123" } }` becomes `{ billing_address: { "kizlo/tax-id": "GB123" } }` on the Store API wire.
|
|
100
|
+
The native value maps to the official registered `kizlo/tax-id` address field. For example, `{ billingAddress: { taxId: "GB123" } }` becomes `{ billing_address: { "kizlo/tax-id": "GB123" } }` on the Store API wire. Cart/customer-address updates and checkout confirm/retry omit the key when `taxId` is omitted, preserving the saved value. Send `taxId: ""` to clear it explicitly. WooCommerce owns sanitization and contextual requiredness.
|
|
58
101
|
|
|
59
102
|
Raw introspection preserves `kizlo/tax-id` in both address schemas. Normalized billing `additionalFields` omits it from types and values: use the native property. Raw billing inputs using that key are rejected even when a duplicate equals `taxId`; there is no raw-only compatibility alias. Other registered and compatible unknown response extras retain their usual buckets.
|
|
60
103
|
|
|
61
|
-
Registered billing extras retain their named enum and scalar types in reads, partial cart updates, and
|
|
104
|
+
Registered billing extras retain their named enum and scalar types in reads, partial cart updates, and confirmation/retry inputs, including registrations with a scalar string index. Confirmation and retry require the registered answers and reject values outside their enums; partial cart updates allow omitted answers. These are compile-time guarantees from the consumer's registered contract. WooCommerce continues to validate against its live registry at runtime.
|
|
62
105
|
|
|
63
106
|
Customer reads use the grouped `billing.additional_fields` adapter backed by public CheckoutFields helpers. Orders read their own snapshot, never the current profile. Storage remains `_wc_billing/kizlo/tax-id`, so existing saved values need no migration. Order admin edits set/replace/clear the order alone; profile edits affect later cart hydration. The retry validation/persistence bridge and shipping cleanup remain required on WooCommerce 11.0.1.
|
|
64
107
|
|