@liquidcommerce/elements-sdk 2.6.0-beta.9 → 2.6.0-beta.91
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 +84 -2520
- package/dist/index.checkout.esm.js +16946 -0
- package/dist/index.esm.js +24448 -21193
- package/dist/ssr-stub.checkout.esm.js +18 -0
- package/dist/ssr-stub.esm.js +270 -0
- package/dist/types/auto-initialize/checkout.d.ts +2 -0
- package/dist/types/auto-initialize/shared-utils.d.ts +50 -0
- package/dist/types/{elements-base-client.d.ts → clients/base.d.ts} +15 -2
- package/dist/types/clients/builder.d.ts +3 -0
- package/dist/types/clients/checkout.d.ts +6 -0
- package/dist/types/{elements-client-helper.d.ts → clients/helpers.d.ts} +2 -1
- package/dist/types/clients/main.d.ts +3 -0
- package/dist/types/constants/core.constant.d.ts +2 -6
- package/dist/types/core/api/api-client.service.d.ts +20 -18
- package/dist/types/core/api/api-result.d.ts +19 -0
- package/dist/types/core/api/auth-client.service.d.ts +37 -13
- package/dist/types/core/api/http-client.service.d.ts +0 -8
- package/dist/types/core/base-component.service.d.ts +2 -1
- package/dist/types/core/client/actions/base-action.service.d.ts +22 -0
- package/dist/types/core/client/actions/client-address-action.service.d.ts +18 -0
- package/dist/types/core/client/actions/client-cart-action.service.d.ts +38 -0
- package/dist/types/core/client/actions/client-checkout-action.service.d.ts +69 -0
- package/dist/types/core/client/actions/client-product-action.service.d.ts +15 -0
- package/dist/types/core/client/client-action.service.d.ts +6 -74
- package/dist/types/core/client/client-config.service.d.ts +8 -5
- package/dist/types/core/google-tag-manager.service.d.ts +2 -1
- package/dist/types/core/logger/logger.service.d.ts +1 -1
- package/dist/types/core/pubsub/interfaces/address.interface.d.ts +3 -0
- package/dist/types/core/pubsub/interfaces/cart.interface.d.ts +1 -1
- package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +36 -51
- package/dist/types/core/pubsub/interfaces/core.interface.d.ts +11 -6
- package/dist/types/core/pubsub/pubsub.service.d.ts +1 -2
- package/dist/types/core/singleton-manager.service.d.ts +12 -8
- package/dist/types/core/store/interfaces/cart.interface.d.ts +2 -3
- package/dist/types/core/store/interfaces/checkout.interface.d.ts +18 -108
- package/dist/types/core/store/interfaces/core.interface.d.ts +12 -2
- package/dist/types/core/store/interfaces/metadata.interface.d.ts +11 -0
- package/dist/types/core/store/interfaces/product-list.interface.d.ts +30 -0
- package/dist/types/core/store/interfaces/product.interface.d.ts +1 -0
- package/dist/types/core/store/store.constant.d.ts +5 -0
- package/dist/types/core/store/store.service.d.ts +1 -0
- package/dist/types/core/telemetry/telemetry.service.d.ts +1 -0
- package/dist/types/enums/core.enum.d.ts +39 -1
- package/dist/types/enums/index.d.ts +0 -1
- package/dist/types/index.checkout.d.ts +8 -0
- package/dist/types/index.checkout.umd.d.ts +4 -0
- package/dist/types/index.d.ts +8 -3
- package/dist/types/interfaces/api/cart.interface.d.ts +12 -7
- package/dist/types/interfaces/api/checkout.interface.d.ts +239 -0
- package/dist/types/interfaces/api/index.d.ts +5 -0
- package/dist/types/interfaces/api/product-list.interface.d.ts +39 -0
- package/dist/types/interfaces/api/product.interface.d.ts +10 -4
- package/dist/types/interfaces/client.interface.d.ts +72 -0
- package/dist/types/interfaces/component.interface.d.ts +7 -0
- package/dist/types/interfaces/config.interface.d.ts +40 -0
- package/dist/types/interfaces/configs/address.interface.d.ts +1 -1
- package/dist/types/interfaces/configs/cart.interface.d.ts +1 -1
- package/dist/types/interfaces/configs/checkout.interface.d.ts +2 -1
- package/dist/types/interfaces/configs/global.interface.d.ts +5 -3
- package/dist/types/interfaces/configs/index.d.ts +1 -0
- package/dist/types/interfaces/configs/product-list.interface.d.ts +49 -0
- package/dist/types/interfaces/configs/product.interface.d.ts +3 -1
- package/dist/types/interfaces/injection.interface.d.ts +49 -0
- package/dist/types/modules/address/address.command.d.ts +2 -1
- package/dist/types/modules/address/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/cart/cart.commands.d.ts +4 -4
- package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/checkout/checkout.commands.d.ts +26 -10
- package/dist/types/modules/checkout/checkout.component.d.ts +2 -0
- package/dist/types/modules/checkout/components/checkout-billing.component.d.ts +2 -2
- package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +3 -0
- package/dist/types/modules/checkout/components/checkout-header.component.d.ts +1 -0
- package/dist/types/modules/checkout/components/checkout-item-quantity.component.d.ts +3 -0
- package/dist/types/modules/checkout/components/checkout-items.component.d.ts +4 -3
- package/dist/types/modules/checkout/components/checkout-payment.component.d.ts +1 -1
- package/dist/types/modules/checkout/components/checkout-presale-countdown.component.d.ts +14 -1
- package/dist/types/modules/checkout/components/checkout-presale-expired.component.d.ts +7 -1
- package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
- package/dist/types/modules/checkout/components/checkout-tips.component.d.ts +2 -2
- package/dist/types/modules/checkout/components/promo-pc-gc.component.d.ts +0 -2
- package/dist/types/modules/checkout/constant.d.ts +3 -0
- package/dist/types/modules/checkout/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/product/components/product-add-to-cart-section.component.d.ts +1 -0
- package/dist/types/modules/product/components/product-description.component.d.ts +1 -0
- package/dist/types/modules/product/components/product-image-carousel.component.d.ts +3 -0
- package/dist/types/modules/product/components/product-options.component.d.ts +2 -1
- package/dist/types/modules/product/components/product-retailers-carousel.component.d.ts +3 -0
- package/dist/types/modules/product/components/product-retailers-popup-list.component.d.ts +5 -2
- package/dist/types/modules/product/product.commands.d.ts +3 -3
- package/dist/types/modules/product/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/product-list/components/card-components/index.d.ts +5 -0
- package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +9 -0
- package/dist/types/modules/product-list/components/card-components/product-button.d.ts +11 -0
- package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +13 -0
- package/dist/types/modules/product-list/components/card-components/product-quantity-selector.d.ts +10 -0
- package/dist/types/modules/product-list/components/card-components/product-sizes-list.d.ts +13 -0
- package/dist/types/modules/product-list/components/filter-components/index.d.ts +7 -0
- package/dist/types/modules/product-list/components/filter-components/product-list-apply-filter-button.d.ts +1 -0
- package/dist/types/modules/product-list/components/filter-components/product-list-chip.d.ts +5 -0
- package/dist/types/modules/product-list/components/filter-components/product-list-filters-chips.d.ts +13 -0
- package/dist/types/modules/product-list/components/filter-components/product-list-fulfillment-filter.d.ts +14 -0
- package/dist/types/modules/product-list/components/{product-list-filters-subcomponents/product-list-price-filter.components.d.ts → filter-components/product-list-price-filter.d.ts} +1 -1
- package/dist/types/modules/product-list/components/filter-components/product-list-toggle-filters.d.ts +7 -0
- package/dist/types/modules/product-list/components/index.d.ts +6 -2
- package/dist/types/modules/product-list/components/product-list-card-loading.component.d.ts +3 -1
- package/dist/types/modules/product-list/components/product-list-card.component.d.ts +36 -31
- package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +12 -0
- package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +55 -36
- package/dist/types/modules/product-list/components/product-list-product-engraving-lines.component.d.ts +22 -0
- package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +50 -0
- package/dist/types/modules/product-list/components/product-list-search.component.d.ts +25 -0
- package/dist/types/modules/product-list/product-list-filter.utils.d.ts +8 -0
- package/dist/types/modules/product-list/product-list-query-params.utils.d.ts +3 -0
- package/dist/types/modules/product-list/product-list.commands.d.ts +23 -8
- package/dist/types/modules/product-list/product-list.component.d.ts +14 -47
- package/dist/types/modules/product-list/product-list.constants.d.ts +38 -0
- package/dist/types/modules/product-list/product-list.interface.d.ts +20 -35
- package/dist/types/modules/product-list/styles/product-list-card.style.d.ts +1 -0
- package/dist/types/modules/product-list/styles/product-list-filters.style.d.ts +1 -0
- package/dist/types/modules/product-list/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/theme-provider/constants/component-groupings.d.ts +1 -0
- package/dist/types/modules/theme-provider/constants/css-variable-mappings.d.ts +1 -1
- package/dist/types/modules/theme-provider/services/style-registry.service.d.ts +16 -0
- package/dist/types/modules/theme-provider/services/stylesheet-generator.service.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/theme-provider/theme-provider.service.d.ts +2 -2
- package/dist/types/modules/ui-components/drawer/drawer.component.d.ts +1 -0
- package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +6 -1
- package/dist/types/modules/ui-components/engraving/engraving-view.component.d.ts +6 -1
- package/dist/types/modules/ui-components/input/index.d.ts +0 -1
- package/dist/types/modules/ui-components/input/input.component.d.ts +8 -1
- package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
- package/dist/types/modules/ui-components/promo-code-ticker/promo-code-ticker.component.d.ts +1 -1
- package/dist/types/modules/ui-components/ui.commands.d.ts +5 -1
- package/dist/types/ssr/stub.checkout.d.ts +6 -0
- package/dist/types/ssr/stub.d.ts +10 -0
- package/dist/types/static/icon/check.icon.d.ts +2 -0
- package/dist/types/static/icon/index.d.ts +1 -0
- package/dist/types/utils/dom-compat.d.ts +2 -0
- package/dist/types/utils/format.d.ts +0 -14
- package/dist/types/utils/image-bg-removal.d.ts +3 -0
- package/dist/types/utils/product-selection.d.ts +16 -0
- package/dist/types/utils/product.d.ts +15 -0
- package/docs/v1/README.md +210 -0
- package/docs/v1/api/actions/address-actions.md +286 -0
- package/docs/v1/api/actions/cart-actions.md +357 -0
- package/docs/v1/api/actions/checkout-actions.md +525 -0
- package/docs/v1/api/actions/product-actions.md +204 -0
- package/docs/v1/api/client.md +517 -0
- package/docs/v1/api/configuration.md +532 -0
- package/docs/v1/api/injection-methods.md +292 -0
- package/docs/v1/api/typescript-types.md +419 -0
- package/docs/v1/api/ui-helpers.md +200 -0
- package/docs/v1/examples/advanced-patterns.md +199 -0
- package/docs/v1/examples/checkout-flow.md +90 -0
- package/docs/v1/examples/custom-theming.md +63 -0
- package/docs/v1/examples/multi-product-page.md +90 -0
- package/docs/v1/examples/simple-product-page.md +89 -0
- package/docs/v1/getting-started/concepts.md +502 -0
- package/docs/v1/getting-started/installation.md +328 -0
- package/docs/v1/getting-started/quick-start.md +405 -0
- package/docs/v1/guides/address-component.md +435 -0
- package/docs/v1/guides/best-practices.md +365 -0
- package/docs/v1/guides/cart-component.md +725 -0
- package/docs/v1/guides/checkout-component.md +670 -0
- package/docs/v1/guides/events.md +926 -0
- package/docs/v1/guides/product-component.md +731 -0
- package/docs/v1/guides/product-list-component.md +631 -0
- package/docs/v1/guides/theming.md +213 -0
- package/docs/v1/integration/angular.md +39 -0
- package/docs/v1/integration/laravel.md +41 -0
- package/docs/v1/integration/nextjs.md +69 -0
- package/docs/v1/integration/proxy-setup.md +106 -0
- package/docs/v1/integration/react.md +64 -0
- package/docs/v1/integration/vanilla-js.md +84 -0
- package/docs/v1/integration/vue.md +58 -0
- package/docs/v1/reference/browser-support.md +45 -0
- package/docs/v1/reference/error-handling.md +75 -0
- package/docs/v1/reference/performance.md +52 -0
- package/docs/v1/reference/troubleshooting.md +136 -0
- package/package.json +33 -37
- package/dist/types/elements-builder-client.d.ts +0 -2
- package/dist/types/elements-client.d.ts +0 -2
- package/dist/types/enums/cloud.enum.d.ts +0 -106
- package/dist/types/interfaces/cloud/catalog.interface.d.ts +0 -42
- package/dist/types/interfaces/cloud/checkout.interface.d.ts +0 -218
- package/dist/types/interfaces/cloud/core.interface.d.ts +0 -22
- package/dist/types/interfaces/cloud/index.d.ts +0 -4
- package/dist/types/interfaces/cloud/retailer.interface.d.ts +0 -67
- package/dist/types/interfaces/cloud/user.interface.d.ts +0 -100
- package/dist/types/interfaces/core.interface.d.ts +0 -111
- package/dist/types/modules/checkout/components/checkout.type.d.ts +0 -4
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/index.d.ts +0 -6
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-apply-filter-button.component.d.ts +0 -1
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-delivery-options-filter.components.d.ts +0 -16
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-search.component.d.ts +0 -16
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-toggle-filters.components.d.ts +0 -18
- package/dist/types/modules/theme-provider/styles/address/index.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/cart/index.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/checkout/index.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/product/index.d.ts +0 -3
- package/dist/types/modules/theme-provider/styles/product-list/index.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/ui/index.d.ts +0 -3
- package/dist/types/modules/ui-components/input/birthdate-input.component.d.ts +0 -53
- package/dist/types/utils/helper.d.ts +0 -28
- package/docs/ACTIONS.md +0 -1300
- package/docs/BROWSER_SUPPORT.md +0 -279
- package/docs/CONFIGURATION.md +0 -853
- package/docs/DOCUMENTATION_INDEX.md +0 -311
- package/docs/EVENTS.md +0 -798
- package/docs/PROXY.md +0 -228
- package/docs/THEMING.md +0 -592
- package/docs/TROUBLESHOOTING.md +0 -793
- package/umd/elements.js +0 -1
- /package/dist/types/{auto-initialize.d.ts → auto-initialize/main.d.ts} +0 -0
- /package/dist/types/modules/{theme-provider/styles/address → address/styles}/address.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/cart → cart/styles}/cart.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/checkout → checkout/styles}/checkout.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/product → product/styles}/image-carousel.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/product → product/styles}/product.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/product → product/styles}/retailers.style.d.ts +0 -0
- /package/dist/types/modules/product-list/components/{product-list-filters-subcomponents/product-list-checkbox-filter.components.d.ts → filter-components/product-list-checkbox-filter.d.ts} +0 -0
- /package/dist/types/modules/{theme-provider/styles/product-list → product-list/styles}/product-list.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/drawer.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/loading.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/promo-code-ticker.style.d.ts +0 -0
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
# Checkout Actions API
|
|
2
|
+
|
|
3
|
+
Checkout actions allow you to programmatically control the checkout flow.
|
|
4
|
+
|
|
5
|
+
## Navigation Actions
|
|
6
|
+
|
|
7
|
+
### actions.checkout.openCheckout()
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
openCheckout(): void
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Opens the checkout drawer or navigates to checkout page.
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
window.LiquidCommerce.elements.actions.checkout.openCheckout();
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### actions.checkout.closeCheckout()
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
closeCheckout(): void
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Closes the checkout drawer.
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
window.LiquidCommerce.elements.actions.checkout.closeCheckout();
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### actions.checkout.toggleCheckout()
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
toggleCheckout(): void
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Toggles checkout open/closed.
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
window.LiquidCommerce.elements.actions.checkout.toggleCheckout();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### actions.checkout.exitCheckout()
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
exitCheckout(): void
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Navigates away from checkout (requires `exitUrl` configuration).
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
window.LiquidCommerce.elements.actions.checkout.exitCheckout();
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Product Actions
|
|
56
|
+
|
|
57
|
+
### actions.checkout.addProduct()
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
addProduct(params: IAddProductParams[], openCheckout?: boolean): Promise<void>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Add products and open checkout in one call. Products are added to the cart (via the cart action, or directly when none is wired up), then checkout is prepared and opened. For a checkout without a cart session, use `addAnonymousProduct`.
|
|
64
|
+
|
|
65
|
+
`IAddProductParams.engravingLines?: string[]` — optional engraving. Same rules as [`actions.cart.addProduct()`](./cart-actions.md#actionscartaddproduct): invalid input is ignored, blanks stripped, lines clamped to the product's `maxLines` / `maxCharsPerLine`, and engraving is dropped (without failing) when the product, variant, or fulfillment doesn't support it.
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
await window.LiquidCommerce.elements.actions.checkout.addProduct([
|
|
69
|
+
{
|
|
70
|
+
identifier: '00619947000020',
|
|
71
|
+
fulfillmentType: 'shipping',
|
|
72
|
+
quantity: 1
|
|
73
|
+
}
|
|
74
|
+
], true); // Open checkout after adding
|
|
75
|
+
|
|
76
|
+
// With engraving
|
|
77
|
+
await window.LiquidCommerce.elements.actions.checkout.addProduct([
|
|
78
|
+
{
|
|
79
|
+
identifier: '00619947000020',
|
|
80
|
+
fulfillmentType: 'shipping',
|
|
81
|
+
quantity: 1,
|
|
82
|
+
engravingLines: ['For Dad']
|
|
83
|
+
}
|
|
84
|
+
], true);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### actions.checkout.addAnonymousProduct()
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
addAnonymousProduct(
|
|
91
|
+
params: IAnonymousCheckoutAddProductParams
|
|
92
|
+
): Promise<IAnonymousCheckoutAddProductResponse>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Add a product to checkout without requiring a cart session. Used for direct-to-checkout flows.
|
|
96
|
+
|
|
97
|
+
**Parameters** (`IAnonymousCheckoutAddProductParams`):
|
|
98
|
+
|
|
99
|
+
| Field | Type | Required | Description |
|
|
100
|
+
|-------|------|----------|-------------|
|
|
101
|
+
| `location` | `ILocation` | Yes | `{ address: IAddressAddress; coordinates: IAddressCoordinates }` |
|
|
102
|
+
| `items` | `IAnonymousCheckoutAddProductItem[]` | No | Products to add: `{ identifier, fulfillmentType, quantity }`. Provide `items` **or** `cartItems`. |
|
|
103
|
+
| `cartItems` | `ICartUpdateItem[]` | No | Pre-resolved cart line items: `{ id?, partNumber, quantity, fulfillmentId, engravingLines? }` (alternative to `items`). |
|
|
104
|
+
| `promoCode` | `string` | No | Promo code applied while creating the anonymous checkout. |
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
const result = await window.LiquidCommerce.elements.actions.checkout
|
|
108
|
+
.addAnonymousProduct({
|
|
109
|
+
items: [
|
|
110
|
+
{ identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }
|
|
111
|
+
],
|
|
112
|
+
location: {
|
|
113
|
+
address: { one: '123 Main St', two: '', city: 'New York', state: 'NY', zip: '10001', country: 'US' },
|
|
114
|
+
coordinates: { latitude: 40.7128, longitude: -74.006 }
|
|
115
|
+
},
|
|
116
|
+
promoCode: 'WELCOME10' // optional
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Returns** (`IAnonymousCheckoutAddProductResponse`):
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
interface IAnonymousCheckoutAddProductResponse {
|
|
124
|
+
checkout: ICheckoutPrepare | null; // the prepared checkout (see below), or null on failure
|
|
125
|
+
unavailableItems: IAnonymousCheckoutUnavailableItem[];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface IAnonymousCheckoutUnavailableItem {
|
|
129
|
+
identifier: string;
|
|
130
|
+
productName: string | null;
|
|
131
|
+
fulfillmentType: FulfillmentType; // 'shipping' | 'onDemand'
|
|
132
|
+
reason: 'product_not_available' | 'fulfillment_not_available';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface ICheckoutPrepare {
|
|
136
|
+
token: string;
|
|
137
|
+
cartId: string;
|
|
138
|
+
customer: ICheckoutCustomer;
|
|
139
|
+
isGift: boolean;
|
|
140
|
+
billingSameAsShipping: boolean;
|
|
141
|
+
payment?: string;
|
|
142
|
+
giftOptions: ICheckoutGiftRecipient;
|
|
143
|
+
marketingPreferences: ICheckoutMarketingPreferences;
|
|
144
|
+
shippingAddress: ICheckoutShippingAddress;
|
|
145
|
+
billingAddress: ICheckoutBilling;
|
|
146
|
+
promoCode: ICheckoutPromoCode | null;
|
|
147
|
+
amounts: ICheckoutAmounts;
|
|
148
|
+
giftCards: ICheckoutGiftCard[];
|
|
149
|
+
presale: ICheckoutPresale | null;
|
|
150
|
+
itemsQuantity: number;
|
|
151
|
+
items: Record<string /* cart item ID */, ICheckoutItem>;
|
|
152
|
+
retailers: Record<string /* retailer ID */, ICheckoutRetailer>;
|
|
153
|
+
events: ICheckoutEvent[];
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Promo & Gift Card Actions
|
|
158
|
+
|
|
159
|
+
### actions.checkout.applyPromoCode()
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
applyPromoCode(promoCode: string): Promise<void>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Apply a promo code during checkout.
|
|
166
|
+
|
|
167
|
+
```javascript
|
|
168
|
+
await window.LiquidCommerce.elements.actions.checkout.applyPromoCode('WELCOME10');
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### actions.checkout.removePromoCode()
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
removePromoCode(): Promise<void>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Remove the active promo code.
|
|
178
|
+
|
|
179
|
+
```javascript
|
|
180
|
+
await window.LiquidCommerce.elements.actions.checkout.removePromoCode();
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### actions.checkout.applyGiftCard()
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
applyGiftCard(code: string): Promise<void>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Apply a gift card.
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
await window.LiquidCommerce.elements.actions.checkout.applyGiftCard('GIFT-1234-5678-9012');
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### actions.checkout.removeGiftCard()
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
removeGiftCard(code: string): Promise<void>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Remove a gift card.
|
|
202
|
+
|
|
203
|
+
```javascript
|
|
204
|
+
await window.LiquidCommerce.elements.actions.checkout.removeGiftCard('GIFT-1234-5678-9012');
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Toggle Actions
|
|
208
|
+
|
|
209
|
+
### actions.checkout.toggleIsGift()
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
toggleIsGift(active?: boolean): Promise<void>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Enable/disable gift mode.
|
|
216
|
+
|
|
217
|
+
```javascript
|
|
218
|
+
// Enable
|
|
219
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleIsGift(true);
|
|
220
|
+
|
|
221
|
+
// Disable
|
|
222
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleIsGift(false);
|
|
223
|
+
|
|
224
|
+
// Toggle
|
|
225
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleIsGift();
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### actions.checkout.toggleBillingSameAsShipping()
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
toggleBillingSameAsShipping(active?: boolean): Promise<void>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Set whether billing address matches shipping.
|
|
235
|
+
|
|
236
|
+
```javascript
|
|
237
|
+
// Use shipping address for billing
|
|
238
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleBillingSameAsShipping(true);
|
|
239
|
+
|
|
240
|
+
// Use different billing address
|
|
241
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleBillingSameAsShipping(false);
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### actions.checkout.toggleMarketingPreferences()
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
toggleMarketingPreferences(field: 'canEmail' | 'canSms', active: boolean): Promise<void>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Set marketing opt-in preferences.
|
|
251
|
+
|
|
252
|
+
```javascript
|
|
253
|
+
// Opt into email marketing
|
|
254
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
|
|
255
|
+
|
|
256
|
+
// Opt into SMS marketing
|
|
257
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleMarketingPreferences('canSms', true);
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Form Update Actions
|
|
261
|
+
|
|
262
|
+
### actions.checkout.updateCustomerInfo()
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
updateCustomerInfo(params: Record<CustomerFieldName, string>): void
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Pre-fill customer information.
|
|
269
|
+
|
|
270
|
+
**Available fields:**
|
|
271
|
+
- `firstName`, `lastName`
|
|
272
|
+
- `email`, `phone`
|
|
273
|
+
- `birthDate`, `addressTwo`
|
|
274
|
+
- `company`
|
|
275
|
+
|
|
276
|
+
```javascript
|
|
277
|
+
window.LiquidCommerce.elements.actions.checkout.updateCustomerInfo({
|
|
278
|
+
firstName: 'John',
|
|
279
|
+
lastName: 'Doe',
|
|
280
|
+
email: 'john@example.com',
|
|
281
|
+
phone: '+15551234567',
|
|
282
|
+
birthDate: '1990-01-01',
|
|
283
|
+
addressTwo: 'Apt 4B',
|
|
284
|
+
company: 'Acme Corp'
|
|
285
|
+
});
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### actions.checkout.updateBillingInfo()
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
updateBillingInfo(params: Record<BillingFieldName, string>): void
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Pre-fill billing address.
|
|
295
|
+
|
|
296
|
+
**Available fields:**
|
|
297
|
+
- `firstName`, `lastName`
|
|
298
|
+
- `email`, `phone`, `company`
|
|
299
|
+
- `addressOne`, `addressTwo`
|
|
300
|
+
- `city`, `state`, `zipCode`
|
|
301
|
+
|
|
302
|
+
```javascript
|
|
303
|
+
window.LiquidCommerce.elements.actions.checkout.updateBillingInfo({
|
|
304
|
+
firstName: 'John',
|
|
305
|
+
lastName: 'Doe',
|
|
306
|
+
email: 'john@example.com',
|
|
307
|
+
phone: '+15551234567',
|
|
308
|
+
company: 'Acme Corp',
|
|
309
|
+
addressOne: '123 Main St',
|
|
310
|
+
addressTwo: 'Apt 4B',
|
|
311
|
+
city: 'New York',
|
|
312
|
+
state: 'NY',
|
|
313
|
+
zipCode: '10001'
|
|
314
|
+
});
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### actions.checkout.updateGiftInfo()
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
updateGiftInfo(params: Record<GiftFieldName, string>): void
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Pre-fill gift recipient information.
|
|
324
|
+
|
|
325
|
+
**Available fields:**
|
|
326
|
+
- `firstName`, `lastName`
|
|
327
|
+
- `email`, `phone`
|
|
328
|
+
- `message`, `addressTwo`
|
|
329
|
+
|
|
330
|
+
```javascript
|
|
331
|
+
window.LiquidCommerce.elements.actions.checkout.updateGiftInfo({
|
|
332
|
+
firstName: 'Jane',
|
|
333
|
+
lastName: 'Smith',
|
|
334
|
+
email: 'jane@example.com',
|
|
335
|
+
phone: '+15559876543',
|
|
336
|
+
addressTwo: 'Suite 200',
|
|
337
|
+
message: 'Happy Birthday!',
|
|
338
|
+
});
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Payment Method
|
|
342
|
+
|
|
343
|
+
### actions.checkout.setSavedPaymentMethod()
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
setSavedPaymentMethod(params: {
|
|
347
|
+
id: string;
|
|
348
|
+
card: {
|
|
349
|
+
brand: string;
|
|
350
|
+
last4: string;
|
|
351
|
+
expMonth?: string | number;
|
|
352
|
+
expYear?: string | number;
|
|
353
|
+
};
|
|
354
|
+
}): void
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Pre-select a saved payment method for the checkout. When set, the payment step renders a read-only card summary (e.g. `Visa ending in 4242`) instead of the Stripe card form, and the shopper places the order without re-entering card details. The `id` is bound to the checkout when the payment form is saved.
|
|
358
|
+
|
|
359
|
+
`id` must be a payment method the backend already holds for the checkout's customer (for example, a card fetched server-side and handed to the page). If the backend does not recognize the `id` for this checkout's customer, saving the payment step fails with an error (`The selected payment method could not be applied to this checkout.`) and the order cannot be placed — pass only a payment method confirmed to belong to the customer. The `card` fields are used only to render the summary. It can be set at any time — before opening checkout, or while it is open — and the payment step updates accordingly. The selection persists across a cart reset within the session.
|
|
360
|
+
|
|
361
|
+
```javascript
|
|
362
|
+
window.LiquidCommerce.elements.actions.checkout.setSavedPaymentMethod({
|
|
363
|
+
id: 'pm_123',
|
|
364
|
+
card: { brand: 'Visa', last4: '4242', expMonth: '12', expYear: '30' }
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### actions.checkout.clearSavedPaymentMethod()
|
|
369
|
+
|
|
370
|
+
```typescript
|
|
371
|
+
clearSavedPaymentMethod(): void
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Remove a previously set saved payment method, restoring the Stripe card-entry form.
|
|
375
|
+
|
|
376
|
+
```javascript
|
|
377
|
+
window.LiquidCommerce.elements.actions.checkout.clearSavedPaymentMethod();
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
## Data Retrieval
|
|
381
|
+
|
|
382
|
+
### actions.checkout.getDetails()
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
getDetails(): ICheckoutDetailsEventData
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Retrieve current checkout information.
|
|
389
|
+
|
|
390
|
+
```javascript
|
|
391
|
+
const checkout = window.LiquidCommerce.elements.actions.checkout.getDetails();
|
|
392
|
+
|
|
393
|
+
console.log(`Cart ID: ${checkout.cartId}`);
|
|
394
|
+
console.log(`Total: $${checkout.amounts.total / 100}`);
|
|
395
|
+
console.log(`Items: ${checkout.itemCount}`);
|
|
396
|
+
console.log(`Is Gift: ${checkout.isGift}`);
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**Returns:**
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
interface ICheckoutDetailsEventData {
|
|
403
|
+
token: string;
|
|
404
|
+
cartId: string;
|
|
405
|
+
isGift: boolean;
|
|
406
|
+
billingSameAsShipping: boolean;
|
|
407
|
+
marketingPreferences: {
|
|
408
|
+
canEmail: boolean;
|
|
409
|
+
canSms: boolean;
|
|
410
|
+
};
|
|
411
|
+
hasPromoCode: boolean;
|
|
412
|
+
hasGiftCards: boolean;
|
|
413
|
+
amounts: ICheckoutAmounts;
|
|
414
|
+
itemCount: number;
|
|
415
|
+
items: Record<string, ICheckoutItem>;
|
|
416
|
+
}
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### actions.checkout.getProductAvailabilityByState()
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
getProductAvailabilityByState(
|
|
423
|
+
identifiers: string[],
|
|
424
|
+
state?: string
|
|
425
|
+
): Promise<IProductAvailabilityResponse>
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Check product availability across states from the checkout context.
|
|
429
|
+
|
|
430
|
+
```javascript
|
|
431
|
+
const availability = await window.LiquidCommerce.elements.actions.checkout
|
|
432
|
+
.getProductAvailabilityByState(['00619947000020'], 'CA');
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
| Parameter | Type | Required | Description |
|
|
436
|
+
|---------------|----------|----------|--------------------------------------|
|
|
437
|
+
| `identifiers` | string[] | Yes | Array of product UPCs, SKUs, or IDs |
|
|
438
|
+
| `state` | string | No | Two-letter state code (e.g., `'NY'`) |
|
|
439
|
+
|
|
440
|
+
## Use Cases
|
|
441
|
+
|
|
442
|
+
### Pre-fill for Logged-In Users
|
|
443
|
+
|
|
444
|
+
```javascript
|
|
445
|
+
window.addEventListener('lce:actions.checkout_opened', () => {
|
|
446
|
+
if (userIsLoggedIn) {
|
|
447
|
+
window.LiquidCommerce.elements.actions.checkout.updateCustomerInfo({
|
|
448
|
+
firstName: currentUser.firstName,
|
|
449
|
+
lastName: currentUser.lastName,
|
|
450
|
+
email: currentUser.email,
|
|
451
|
+
phone: currentUser.phone
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Track Checkout Progress
|
|
458
|
+
|
|
459
|
+
```javascript
|
|
460
|
+
window.addEventListener('lce:actions.checkout_customer_information_updated', () => {
|
|
461
|
+
gtag('event', 'checkout_progress', { step: 'customer_info' });
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
window.addEventListener('lce:actions.checkout_submit_started', () => {
|
|
465
|
+
gtag('event', 'checkout_progress', { step: 'payment' });
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
window.addEventListener('lce:actions.checkout_submit_completed', (event) => {
|
|
469
|
+
const { orderNumber, orderTotal } = event.detail.data;
|
|
470
|
+
|
|
471
|
+
gtag('event', 'purchase', {
|
|
472
|
+
transaction_id: orderNumber,
|
|
473
|
+
value: orderTotal / 100,
|
|
474
|
+
currency: 'USD'
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### Gift Flow
|
|
480
|
+
|
|
481
|
+
```javascript
|
|
482
|
+
document.getElementById('gift-checkbox').addEventListener('change', async (e) => {
|
|
483
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleIsGift(e.target.checked);
|
|
484
|
+
|
|
485
|
+
if (e.target.checked) {
|
|
486
|
+
showGiftForm();
|
|
487
|
+
} else {
|
|
488
|
+
hideGiftForm();
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
### Auto-Apply Campaign Codes
|
|
494
|
+
|
|
495
|
+
```javascript
|
|
496
|
+
const params = new URLSearchParams(window.location.search);
|
|
497
|
+
const campaignCode = params.get('promo');
|
|
498
|
+
|
|
499
|
+
if (campaignCode) {
|
|
500
|
+
window.addEventListener('lce:actions.checkout_opened', async () => {
|
|
501
|
+
try {
|
|
502
|
+
await window.LiquidCommerce.elements.actions.checkout.applyPromoCode(campaignCode);
|
|
503
|
+
} catch (error) {
|
|
504
|
+
console.log('Invalid campaign code');
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
## Events
|
|
511
|
+
|
|
512
|
+
Checkout actions trigger numerous events. See [Checkout Events](../../guides/events.md#checkout-events) for complete list.
|
|
513
|
+
|
|
514
|
+
Key events:
|
|
515
|
+
- `checkout_opened`, `checkout_closed`
|
|
516
|
+
- `checkout_customer_information_updated`
|
|
517
|
+
- `checkout_submit_started`, `checkout_submit_completed`, `checkout_submit_failed`
|
|
518
|
+
- `checkout_promo_code_applied`, `checkout_promo_code_failed`
|
|
519
|
+
- `checkout_gift_card_applied`, `checkout_gift_card_failed`
|
|
520
|
+
|
|
521
|
+
## See Also
|
|
522
|
+
|
|
523
|
+
- [Checkout Component Guide](../../guides/checkout-component.md)
|
|
524
|
+
- [Checkout Events](../../guides/events.md#checkout-events)
|
|
525
|
+
- [Cart Actions](./cart-actions.md)
|