@liquidcommerce/elements-sdk 2.6.0-beta.7 → 2.6.0-beta.70
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 +83 -2519
- package/dist/index.checkout.esm.js +16607 -0
- package/dist/index.esm.js +23330 -20416
- 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 +46 -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} +3 -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 +40 -13
- package/dist/types/core/api/http-client.service.d.ts +0 -1
- package/dist/types/core/base-component.service.d.ts +2 -1
- package/dist/types/core/client/actions/base-action.service.d.ts +15 -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 +37 -0
- package/dist/types/core/client/actions/client-checkout-action.service.d.ts +56 -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 -70
- package/dist/types/core/client/client-config.service.d.ts +8 -2
- package/dist/types/core/command/common-command.service.d.ts +1 -0
- 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/cart.interface.d.ts +27 -52
- package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +45 -51
- package/dist/types/core/pubsub/interfaces/core.interface.d.ts +9 -4
- package/dist/types/core/pubsub/interfaces/product.interface.d.ts +16 -74
- 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 +3 -4
- package/dist/types/core/store/interfaces/checkout.interface.d.ts +17 -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 +13 -8
- 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 +41 -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 +47 -0
- package/dist/types/interfaces/configs/product.interface.d.ts +4 -1
- package/dist/types/interfaces/injection.interface.d.ts +47 -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/components/cart-body.component.d.ts +2 -1
- package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/checkout/checkout.commands.d.ts +23 -9
- 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-items.component.d.ts +4 -3
- 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 +2 -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 +9 -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 +9 -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 +2 -1
- package/dist/types/modules/product-list/components/product-list-card.component.d.ts +27 -30
- 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 +49 -0
- package/dist/types/modules/product-list/components/{product-list-filters-subcomponents/product-list-search.component.d.ts → product-list-search.component.d.ts} +11 -4
- package/dist/types/modules/product-list/product-list-filter.utils.d.ts +8 -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 +10 -45
- 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/product-selection.d.ts +16 -0
- package/dist/types/utils/product.d.ts +10 -0
- package/docs/v1/README.md +210 -0
- package/docs/v1/api/actions/address-actions.md +281 -0
- package/docs/v1/api/actions/cart-actions.md +337 -0
- package/docs/v1/api/actions/checkout-actions.md +427 -0
- package/docs/v1/api/actions/product-actions.md +158 -0
- package/docs/v1/api/client.md +495 -0
- package/docs/v1/api/configuration.md +528 -0
- package/docs/v1/api/injection-methods.md +261 -0
- package/docs/v1/api/typescript-types.md +398 -0
- package/docs/v1/api/ui-helpers.md +200 -0
- package/docs/v1/examples/advanced-patterns.md +198 -0
- package/docs/v1/examples/checkout-flow.md +91 -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 +507 -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 +431 -0
- package/docs/v1/guides/best-practices.md +353 -0
- package/docs/v1/guides/cart-component.md +737 -0
- package/docs/v1/guides/checkout-component.md +672 -0
- package/docs/v1/guides/events.md +926 -0
- package/docs/v1/guides/product-component.md +686 -0
- package/docs/v1/guides/product-list-component.md +507 -0
- package/docs/v1/guides/theming.md +216 -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 +89 -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 +44 -0
- package/docs/v1/reference/error-handling.md +70 -0
- package/docs/v1/reference/performance.md +54 -0
- package/docs/v1/reference/troubleshooting.md +136 -0
- package/package.json +31 -27
- 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/cart/cart.commands.helper.d.ts +0 -4
- 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-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,200 @@
|
|
|
1
|
+
# UI Helpers API
|
|
2
|
+
|
|
3
|
+
UI helper methods for creating cart buttons and displaying cart information.
|
|
4
|
+
|
|
5
|
+
## ui.cartButton()
|
|
6
|
+
|
|
7
|
+
Create a cart button in a specific container.
|
|
8
|
+
|
|
9
|
+
### Signature
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
cartButton(containerId: string, showItemsCount?: boolean): void
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Required | Description |
|
|
18
|
+
|-----------|------|----------|-------------|
|
|
19
|
+
| `containerId` | string | Yes | ID of container element |
|
|
20
|
+
| `showItemsCount` | boolean | No | Show item count badge (default: false) |
|
|
21
|
+
|
|
22
|
+
### Example
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
// Simple cart button
|
|
26
|
+
window.LiquidCommerce.elements.ui.cartButton('header-cart');
|
|
27
|
+
|
|
28
|
+
// Cart button with item count badge
|
|
29
|
+
window.LiquidCommerce.elements.ui.cartButton('header-cart', true);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## ui.floatingCartButton()
|
|
35
|
+
|
|
36
|
+
Create a floating cart button (bottom-right corner).
|
|
37
|
+
|
|
38
|
+
### Signature
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
floatingCartButton(showItemsCount?: boolean): void
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Parameters
|
|
45
|
+
|
|
46
|
+
| Parameter | Type | Required | Description |
|
|
47
|
+
|-----------|------|----------|-------------|
|
|
48
|
+
| `showItemsCount` | boolean | No | Show item count badge (default: false) |
|
|
49
|
+
|
|
50
|
+
### Example
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
// Floating button without badge
|
|
54
|
+
window.LiquidCommerce.elements.ui.floatingCartButton();
|
|
55
|
+
|
|
56
|
+
// Floating button with badge
|
|
57
|
+
window.LiquidCommerce.elements.ui.floatingCartButton(true);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## ui.cartSubtotal()
|
|
63
|
+
|
|
64
|
+
Display cart subtotal in an element.
|
|
65
|
+
|
|
66
|
+
### Signature
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
cartSubtotal(elementId: string): void
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Parameters
|
|
73
|
+
|
|
74
|
+
| Parameter | Type | Required | Description |
|
|
75
|
+
|-----------|------|----------|-------------|
|
|
76
|
+
| `elementId` | string | Yes | ID of element to update |
|
|
77
|
+
|
|
78
|
+
### Example
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<div>Total: <span id="cart-total"></span></div>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
window.LiquidCommerce.elements.ui.cartSubtotal('cart-total');
|
|
86
|
+
// Element now shows: "$49.99"
|
|
87
|
+
// Updates automatically when cart changes
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## ui.cartItemsCount()
|
|
93
|
+
|
|
94
|
+
Display number of items in cart.
|
|
95
|
+
|
|
96
|
+
### Signature
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
cartItemsCount(elementId: string, options?: { hideZero: boolean }): void
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Parameters
|
|
103
|
+
|
|
104
|
+
| Parameter | Type | Required | Description |
|
|
105
|
+
|-----------|------|----------|-------------|
|
|
106
|
+
| `elementId` | string | Yes | ID of element to update |
|
|
107
|
+
| `options.hideZero` | boolean | No | Hide when cart is empty (default: true) |
|
|
108
|
+
|
|
109
|
+
### Example
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<div>Cart (<span id="items-count"></span>)</div>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
// Hide when cart is empty
|
|
117
|
+
window.LiquidCommerce.elements.ui.cartItemsCount('items-count', { hideZero: true });
|
|
118
|
+
|
|
119
|
+
// Always show count (even "0")
|
|
120
|
+
window.LiquidCommerce.elements.ui.cartItemsCount('items-count', { hideZero: false });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Use Cases
|
|
124
|
+
|
|
125
|
+
### Header Cart Button
|
|
126
|
+
|
|
127
|
+
```html
|
|
128
|
+
<header>
|
|
129
|
+
<nav>
|
|
130
|
+
<a href="/">Home</a>
|
|
131
|
+
<a href="/products">Products</a>
|
|
132
|
+
<div id="cart-btn"></div>
|
|
133
|
+
</nav>
|
|
134
|
+
</header>
|
|
135
|
+
|
|
136
|
+
<script>
|
|
137
|
+
window.addEventListener('lce:actions.client_ready', () => {
|
|
138
|
+
window.LiquidCommerce.elements.ui.cartButton('cart-btn', true);
|
|
139
|
+
});
|
|
140
|
+
</script>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Cart Summary Widget
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<aside class="cart-summary">
|
|
147
|
+
<h3>Your Cart</h3>
|
|
148
|
+
<p>Items: <span id="item-count"></span></p>
|
|
149
|
+
<p>Total: <span id="cart-total"></span></p>
|
|
150
|
+
</aside>
|
|
151
|
+
|
|
152
|
+
<script>
|
|
153
|
+
window.addEventListener('lce:actions.client_ready', () => {
|
|
154
|
+
window.LiquidCommerce.elements.ui.cartItemsCount('item-count');
|
|
155
|
+
window.LiquidCommerce.elements.ui.cartSubtotal('cart-total');
|
|
156
|
+
});
|
|
157
|
+
</script>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Floating Cart for Mobile
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
// Show floating button only on mobile
|
|
164
|
+
if (window.innerWidth < 768) {
|
|
165
|
+
window.LiquidCommerce.elements.ui.floatingCartButton(true);
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Styling
|
|
170
|
+
|
|
171
|
+
Cart buttons and UI elements can be styled with CSS:
|
|
172
|
+
|
|
173
|
+
```css
|
|
174
|
+
/* Cart button container */
|
|
175
|
+
.lce-cart-desktop-button-container {
|
|
176
|
+
/* Your styles */
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* Cart items count */
|
|
180
|
+
.lce-cart-items-count {
|
|
181
|
+
font-weight: bold;
|
|
182
|
+
color: #007bff;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* When cart is empty */
|
|
186
|
+
.lce-cart-items-count.no-items {
|
|
187
|
+
opacity: 0.5;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* Cart subtotal */
|
|
191
|
+
.lce-cart-subtotal {
|
|
192
|
+
font-size: 1.2em;
|
|
193
|
+
font-weight: bold;
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## See Also
|
|
198
|
+
|
|
199
|
+
- [Cart Component Guide](../guides/cart-component.md)
|
|
200
|
+
- [Cart Actions](./actions/cart-actions.md)
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Advanced Patterns
|
|
2
|
+
|
|
3
|
+
A collection of common production patterns using events, programmatic injection, address prefill, and checkout redirects.
|
|
4
|
+
|
|
5
|
+
## 1) Dynamic Product Injection
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
9
|
+
|
|
10
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
11
|
+
|
|
12
|
+
const products = ['00619947000020', '08504405135', '08068660001'];
|
|
13
|
+
|
|
14
|
+
await client.injectProductElement(
|
|
15
|
+
products.map((identifier, index) => ({
|
|
16
|
+
containerId: `product-${index}`,
|
|
17
|
+
identifier
|
|
18
|
+
}))
|
|
19
|
+
);
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 2) Pre-Set Address (Skip Prompt)
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
await window.LiquidCommerce.elements.actions.address.setAddressManually(
|
|
26
|
+
{
|
|
27
|
+
one: '123 Main St',
|
|
28
|
+
two: 'Apt 4',
|
|
29
|
+
city: 'New York',
|
|
30
|
+
state: 'NY',
|
|
31
|
+
zip: '10001'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
latitude: 40.7128,
|
|
35
|
+
longitude: -74.0060
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 3) Custom Cart Button
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<button data-lce-cart-toggle-button>
|
|
44
|
+
View Cart
|
|
45
|
+
</button>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 4) Analytics With Events
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
window.addEventListener('lce:actions.product_loaded', (event) => {
|
|
52
|
+
const { identifier, name, price } = event.detail.data;
|
|
53
|
+
gtag('event', 'view_item', {
|
|
54
|
+
items: [{ item_id: identifier, item_name: name, price: price / 100 }]
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
window.addEventListener('lce:actions.checkout_submit_completed', (event) => {
|
|
59
|
+
const { orderId, total } = event.detail.data;
|
|
60
|
+
gtag('event', 'purchase', {
|
|
61
|
+
transaction_id: orderId,
|
|
62
|
+
value: total / 100,
|
|
63
|
+
currency: 'USD'
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 5) Redirect Checkout to Your Page
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
72
|
+
env: 'production',
|
|
73
|
+
checkout: {
|
|
74
|
+
pageUrl: 'https://yoursite.com/checkout?lce_checkout={token}'
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 6) Debugging Helpers
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
83
|
+
env: 'production',
|
|
84
|
+
debugMode: 'console',
|
|
85
|
+
development: {
|
|
86
|
+
openShadowDom: true
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## 7) Cleanup on SPA Navigation
|
|
92
|
+
|
|
93
|
+
```javascript
|
|
94
|
+
let client = null;
|
|
95
|
+
|
|
96
|
+
async function mountElements() {
|
|
97
|
+
client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
98
|
+
await client.injectProductElement([
|
|
99
|
+
{ containerId: 'product', identifier: '00619947000020' }
|
|
100
|
+
]);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function unmountElements() {
|
|
104
|
+
if (client) {
|
|
105
|
+
client.destroy();
|
|
106
|
+
client = null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// React example
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
mountElements();
|
|
113
|
+
return () => unmountElements();
|
|
114
|
+
}, []);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## 8) Checkout-Only Page
|
|
118
|
+
|
|
119
|
+
For a dedicated checkout page, use the tree-shaken checkout build:
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
import { ElementsCheckout } from '@liquidcommerce/elements-sdk/checkout';
|
|
123
|
+
|
|
124
|
+
const client = await ElementsCheckout('YOUR_API_KEY', {
|
|
125
|
+
env: 'production'
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
await client.injectCheckout({
|
|
129
|
+
containerId: 'checkout',
|
|
130
|
+
checkoutId: new URLSearchParams(window.location.search).get('lce_checkout'),
|
|
131
|
+
hideHeader: false
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 9) Promo Ticker with Time Windows
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
139
|
+
env: 'production',
|
|
140
|
+
promoTicker: [
|
|
141
|
+
{
|
|
142
|
+
promoCode: 'SUMMER20',
|
|
143
|
+
text: ['20% Off Summer Sale', 'Free Shipping on $50+'],
|
|
144
|
+
separator: '|',
|
|
145
|
+
activeFrom: '2026-06-01T00:00:00Z',
|
|
146
|
+
activeUntil: '2026-08-31T23:59:59Z'
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
promoCode: 'FALL10',
|
|
150
|
+
text: ['10% Off Fall Collection'],
|
|
151
|
+
separator: '|',
|
|
152
|
+
activeFrom: '2026-09-01T00:00:00Z',
|
|
153
|
+
activeUntil: '2026-11-30T23:59:59Z'
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## 10) Product List with Filters and Search
|
|
160
|
+
|
|
161
|
+
```javascript
|
|
162
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
163
|
+
|
|
164
|
+
await client.injectProductListSearch({
|
|
165
|
+
containerId: 'search-box',
|
|
166
|
+
slug: 'whiskey-collection'
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
await client.injectProductListFilters({
|
|
170
|
+
containerId: 'sidebar-filters',
|
|
171
|
+
slug: 'whiskey-collection',
|
|
172
|
+
filters: ['price', 'brands', 'sizes', 'fulfillment']
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
await client.injectProductList({
|
|
176
|
+
containerId: 'product-grid',
|
|
177
|
+
slug: 'whiskey-collection',
|
|
178
|
+
rows: 4,
|
|
179
|
+
columns: 3,
|
|
180
|
+
productUrl: '/products/{identifier}'
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 11) Check Product Availability by State
|
|
185
|
+
|
|
186
|
+
```javascript
|
|
187
|
+
const availability = await window.LiquidCommerce.elements.actions.product
|
|
188
|
+
.getProductAvailabilityByState(['00619947000020', '08504405135'], 'CA');
|
|
189
|
+
|
|
190
|
+
console.log('Availability in CA:', availability);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Related Docs
|
|
194
|
+
|
|
195
|
+
- [Events Guide](../guides/events.md)
|
|
196
|
+
- [Product Component](../guides/product-component.md)
|
|
197
|
+
- [Checkout Component](../guides/checkout-component.md)
|
|
198
|
+
- [Client API](../api/client.md)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Complete Checkout Flow
|
|
2
|
+
|
|
3
|
+
A two-page setup: a product page that adds to cart and redirects to a dedicated checkout page.
|
|
4
|
+
|
|
5
|
+
## What You'll Build
|
|
6
|
+
|
|
7
|
+
- Product page with cart and checkout redirect
|
|
8
|
+
- Dedicated checkout page that loads by URL parameter
|
|
9
|
+
|
|
10
|
+
## Page 1: Product Page
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<!DOCTYPE html>
|
|
14
|
+
<html lang="en">
|
|
15
|
+
<head>
|
|
16
|
+
<meta charset="UTF-8" />
|
|
17
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
18
|
+
<title>Product Page</title>
|
|
19
|
+
|
|
20
|
+
<script
|
|
21
|
+
defer
|
|
22
|
+
data-liquid-commerce-elements
|
|
23
|
+
data-token="YOUR_API_KEY"
|
|
24
|
+
data-env="production"
|
|
25
|
+
data-container-1="product"
|
|
26
|
+
data-product-1="00619947000020"
|
|
27
|
+
data-cart-badge-button="header-cart"
|
|
28
|
+
data-checkout-url="https://yoursite.com/checkout?lce_checkout={token}"
|
|
29
|
+
type="text/javascript"
|
|
30
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
31
|
+
></script>
|
|
32
|
+
</head>
|
|
33
|
+
<body>
|
|
34
|
+
<header>
|
|
35
|
+
<h1>Premium Spirits</h1>
|
|
36
|
+
<div id="header-cart"></div>
|
|
37
|
+
</header>
|
|
38
|
+
|
|
39
|
+
<main>
|
|
40
|
+
<div id="product"></div>
|
|
41
|
+
</main>
|
|
42
|
+
</body>
|
|
43
|
+
</html>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
When users click checkout, the cart redirects to your hosted checkout page with a `lce_checkout` ID in the URL.
|
|
47
|
+
|
|
48
|
+
## Page 2: Checkout Page
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<!DOCTYPE html>
|
|
52
|
+
<html lang="en">
|
|
53
|
+
<head>
|
|
54
|
+
<meta charset="UTF-8" />
|
|
55
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
56
|
+
<title>Checkout</title>
|
|
57
|
+
|
|
58
|
+
<script
|
|
59
|
+
defer
|
|
60
|
+
data-liquid-commerce-elements
|
|
61
|
+
data-token="YOUR_API_KEY"
|
|
62
|
+
data-env="production"
|
|
63
|
+
data-checkout-container="checkout"
|
|
64
|
+
data-checkout-param="lce_checkout"
|
|
65
|
+
type="text/javascript"
|
|
66
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
67
|
+
></script>
|
|
68
|
+
</head>
|
|
69
|
+
<body>
|
|
70
|
+
<div id="checkout"></div>
|
|
71
|
+
</body>
|
|
72
|
+
</html>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Optional: Skip Cart and Go Directly to Checkout
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
await window.LiquidCommerce.elements.actions.checkout.addProduct([
|
|
79
|
+
{
|
|
80
|
+
identifier: '00619947000020',
|
|
81
|
+
fulfillmentType: 'shipping',
|
|
82
|
+
quantity: 1
|
|
83
|
+
}
|
|
84
|
+
], true);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Related Docs
|
|
88
|
+
|
|
89
|
+
- [Checkout Component](../guides/checkout-component.md)
|
|
90
|
+
- [Cart Component](../guides/cart-component.md)
|
|
91
|
+
- [Client API](../api/client.md)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Custom Theming
|
|
2
|
+
|
|
3
|
+
Apply a branded theme across product, cart, and checkout components using `customTheme`.
|
|
4
|
+
|
|
5
|
+
## Example (NPM)
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
9
|
+
|
|
10
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
11
|
+
env: 'production',
|
|
12
|
+
customTheme: {
|
|
13
|
+
global: {
|
|
14
|
+
theme: {
|
|
15
|
+
primaryColor: '#1f4f91',
|
|
16
|
+
accentColor: '#f39c12',
|
|
17
|
+
defaultTextColor: '#1c1c1c',
|
|
18
|
+
buttonCornerRadius: '10px',
|
|
19
|
+
cardCornerRadius: '14px',
|
|
20
|
+
headingFont: {
|
|
21
|
+
name: 'Poppins',
|
|
22
|
+
weights: [400, 600, 700]
|
|
23
|
+
},
|
|
24
|
+
paragraphFont: {
|
|
25
|
+
name: 'Inter',
|
|
26
|
+
weights: [400, 500]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
layout: {
|
|
30
|
+
allowPromoCodes: true,
|
|
31
|
+
inputFieldStyle: 'outlined',
|
|
32
|
+
showPoweredBy: false
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
product: {
|
|
36
|
+
layout: {
|
|
37
|
+
addToCartButtonText: 'Add to Bag',
|
|
38
|
+
fulfillmentDisplay: 'popup',
|
|
39
|
+
showOnlyMainImage: true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
cart: {
|
|
43
|
+
layout: {
|
|
44
|
+
drawerHeaderText: 'Your Cart',
|
|
45
|
+
goToCheckoutButtonText: 'Checkout Now'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
checkout: {
|
|
49
|
+
layout: {
|
|
50
|
+
placeOrderButtonText: 'Place Order',
|
|
51
|
+
exitUrl: 'https://yoursite.com/shop'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
> If you use custom fonts, make sure the font is available on the page.
|
|
59
|
+
|
|
60
|
+
## Related Docs
|
|
61
|
+
|
|
62
|
+
- [Theming Guide](../guides/theming.md)
|
|
63
|
+
- [Configuration Reference](../api/configuration.md)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Multi-Product Page
|
|
2
|
+
|
|
3
|
+
Show multiple products on a single page using declarative attributes or programmatic injection.
|
|
4
|
+
|
|
5
|
+
## Option A: Declarative (Data Attributes)
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!DOCTYPE html>
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="UTF-8" />
|
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
13
|
+
<title>Multi-Product Page</title>
|
|
14
|
+
|
|
15
|
+
<script
|
|
16
|
+
defer
|
|
17
|
+
data-liquid-commerce-elements
|
|
18
|
+
data-token="YOUR_API_KEY"
|
|
19
|
+
data-env="production"
|
|
20
|
+
data-container-1="product-1"
|
|
21
|
+
data-product-1="00619947000020"
|
|
22
|
+
data-container-2="product-2"
|
|
23
|
+
data-product-2="08504405135"
|
|
24
|
+
data-container-3="product-3"
|
|
25
|
+
data-product-3="08068660001"
|
|
26
|
+
type="text/javascript"
|
|
27
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
28
|
+
></script>
|
|
29
|
+
|
|
30
|
+
<style>
|
|
31
|
+
body { font-family: Arial, sans-serif; margin: 0; padding: 24px; background: #f7f7f7; }
|
|
32
|
+
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
|
|
33
|
+
.card { background: #fff; border-radius: 10px; padding: 16px; min-height: 520px; }
|
|
34
|
+
</style>
|
|
35
|
+
</head>
|
|
36
|
+
<body>
|
|
37
|
+
<h1>Featured Products</h1>
|
|
38
|
+
<div class="grid">
|
|
39
|
+
<div id="product-1" class="card"></div>
|
|
40
|
+
<div id="product-2" class="card"></div>
|
|
41
|
+
<div id="product-3" class="card"></div>
|
|
42
|
+
</div>
|
|
43
|
+
</body>
|
|
44
|
+
</html>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Option B: JSON Configuration
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<script
|
|
51
|
+
defer
|
|
52
|
+
data-liquid-commerce-elements
|
|
53
|
+
data-token="YOUR_API_KEY"
|
|
54
|
+
data-env="production"
|
|
55
|
+
type="text/javascript"
|
|
56
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
57
|
+
></script>
|
|
58
|
+
|
|
59
|
+
<script data-liquid-commerce-elements-products type="application/json">
|
|
60
|
+
[
|
|
61
|
+
{ "containerId": "product-1", "identifier": "00619947000020" },
|
|
62
|
+
{ "containerId": "product-2", "identifier": "08504405135" },
|
|
63
|
+
{ "containerId": "product-3", "identifier": "08068660001" }
|
|
64
|
+
]
|
|
65
|
+
</script>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Option C: Programmatic Injection (NPM)
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
72
|
+
|
|
73
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
74
|
+
|
|
75
|
+
await client.injectProductElement([
|
|
76
|
+
{ containerId: 'product-1', identifier: '00619947000020' },
|
|
77
|
+
{ containerId: 'product-2', identifier: '08504405135' },
|
|
78
|
+
{ containerId: 'product-3', identifier: '08068660001' }
|
|
79
|
+
]);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Tips
|
|
83
|
+
|
|
84
|
+
- Give each container a `min-height` to reduce layout shift while data loads.
|
|
85
|
+
- Add a cart button once per page (see [Cart Component](../guides/cart-component.md)).
|
|
86
|
+
|
|
87
|
+
## Related Docs
|
|
88
|
+
|
|
89
|
+
- [Product Component](../guides/product-component.md)
|
|
90
|
+
- [Quick Start](../getting-started/quick-start.md)
|