@kizlo/woocommerce 0.14.1 → 0.16.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 +45 -0
- package/dist/checkout-validation.d.ts +1 -1
- package/dist/index.d.ts +2106 -2100
- package/dist/index.js +52 -13
- package/dist/{schema-ScTHhVY4.d.ts → schema-CWDJjtW7.d.ts} +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -42,6 +42,29 @@ 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
|
+
|
|
45
68
|
## Billing Tax IDs
|
|
46
69
|
|
|
47
70
|
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.
|
|
@@ -70,6 +93,28 @@ Storefront field definitions include SDK binding paths derived from the same add
|
|
|
70
93
|
|
|
71
94
|
Update, confirm, and retry expose `CHECKOUT_VALIDATION_FAILED.data = { issues }`. Registered fields carry literal IDs and normalized SDK buckets for Kit or standalone consumers to match against loaded bindings. The browser entry retains schemas/types; the SDK resolver is removed. See [client handling and Kit requirements](./docs/checkout-validation.md) and the [breaking handler migration](./docs/checkout-validation-migration.md).
|
|
72
95
|
|
|
96
|
+
## Protect a reviewed checkout total
|
|
97
|
+
|
|
98
|
+
Pass optional `expectedTotal` when confirming checkout to protect the amount your shopper reviewed. Capture it with the cart you display, in minor units: `"1250"` means 12.50 in a currency with two decimal places. The input accepts digits-only strings, including `"0"`, and forwards them unchanged as WooCommerce's `expected_total`.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
const reviewedTotal = String(cart.totals.total)
|
|
102
|
+
|
|
103
|
+
const result = await kizlo.client.woocommerce.checkout.confirm({
|
|
104
|
+
body: { ...checkoutInput, expectedTotal: reviewedTotal },
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
if (!result.success && result.error.code === "CHECKOUT_TOTAL_MISMATCH") {
|
|
108
|
+
const { cart: updatedCart, expectedTotal, actualTotal } = result.error.data
|
|
109
|
+
// Display the available evidence and ask the shopper to review again.
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Upgrade `kizlo` to 0.26.1 or later alongside `@kizlo/woocommerce` so browser clients preserve the typed conflict. This protection requires [WooCommerce 11.1.0 or later](https://github.com/woocommerce/woocommerce/blob/11.1.0/plugins/woocommerce/src/StoreApi/Routes/V1/Checkout.php). An increased recalculated total returns `CHECKOUT_TOTAL_MISMATCH` with status 409 before order creation or payment; equal and decreased totals are allowed. Error data contains `cart: Cart | null` and optional minor-unit digit strings `expectedTotal` and `actualTotal`; missing or malformed evidence preserves the conflict. Omit the field for manual or express flows that cannot know the total up front, and on older WooCommerce versions that do not enforce it.
|
|
114
|
+
|
|
115
|
+
- Keep the reviewed amount until the shopper approves a new one. Confirmation performs no cart refresh, amount substitution, or automatic retry.
|
|
116
|
+
- `checkout.retry` pays an existing order through a separate protocol and does not accept `expectedTotal`.
|
|
117
|
+
|
|
73
118
|
## Storefront settings
|
|
74
119
|
|
|
75
120
|
`storefront.get` returns the store-wide settings a storefront renders with, so nothing has to be hardcoded:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { f as CheckoutRegisteredFieldReference, m as CheckoutValidationIssue, o as StorefrontField, p as CheckoutValidationData } from "./schema-
|
|
1
|
+
import { f as CheckoutRegisteredFieldReference, m as CheckoutValidationIssue, o as StorefrontField, p as CheckoutValidationData } from "./schema-CWDJjtW7.js";
|
|
2
2
|
export { CheckoutRegisteredFieldReference, CheckoutValidationData, CheckoutValidationIssue, type StorefrontField };
|