@liquidcommerce/elements-sdk 2.6.7 → 2.7.1
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 +16086 -0
- package/dist/index.esm.js +16267 -13788
- package/dist/types/auto-initialize/checkout.d.ts +2 -0
- package/dist/types/auto-initialize/shared-utils.d.ts +27 -0
- package/dist/types/{elements-base-client.d.ts → clients/base.d.ts} +11 -1
- package/dist/types/clients/checkout.d.ts +13 -0
- package/dist/types/constants/core.constant.d.ts +5 -3
- package/dist/types/core/api/api-client.service.d.ts +0 -2
- 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 +50 -0
- package/dist/types/core/client/actions/client-product-action.service.d.ts +12 -0
- package/dist/types/core/client/client-action.service.d.ts +6 -73
- package/dist/types/core/client/client-config.service.d.ts +3 -4
- package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +1 -0
- package/dist/types/core/store/interfaces/core.interface.d.ts +14 -1
- package/dist/types/core/store/interfaces/metadata.interface.d.ts +11 -0
- package/dist/types/core/store/interfaces/product-list.interface.d.ts +45 -0
- package/dist/types/core/store/interfaces/product.interface.d.ts +1 -0
- package/dist/types/core/store/store.constant.d.ts +4 -0
- package/dist/types/enums/core.enum.d.ts +14 -1
- package/dist/types/enums/index.d.ts +0 -1
- package/dist/types/index.checkout.d.ts +7 -0
- package/dist/types/index.checkout.umd.d.ts +4 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/interfaces/api/checkout.interface.d.ts +2 -1
- package/dist/types/interfaces/api/product-list.interface.d.ts +13 -5
- package/dist/types/interfaces/configs/checkout.interface.d.ts +1 -0
- package/dist/types/interfaces/configs/global.interface.d.ts +4 -2
- package/dist/types/interfaces/configs/index.d.ts +1 -0
- package/dist/types/interfaces/configs/product-list.interface.d.ts +28 -0
- package/dist/types/interfaces/core.interface.d.ts +28 -6
- package/dist/types/modules/address/address-input.component.d.ts +11 -0
- package/dist/types/modules/address/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/checkout/checkout.commands.d.ts +6 -2
- package/dist/types/modules/checkout/checkout.component.d.ts +2 -0
- package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +2 -0
- package/dist/types/modules/checkout/components/checkout-header.component.d.ts +1 -0
- package/dist/types/modules/checkout/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/product/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/product-list/components/card-components/index.d.ts +7 -0
- package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +8 -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-fulfillments.d.ts +12 -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 +9 -0
- package/dist/types/modules/product-list/components/card-components/product-title.d.ts +6 -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 +13 -0
- package/dist/types/modules/product-list/components/index.d.ts +7 -3
- 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-engraving.component.d.ts +10 -0
- package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +58 -37
- package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +28 -0
- package/dist/types/modules/product-list/components/product-list-retailers.component.d.ts +26 -0
- package/dist/types/modules/product-list/components/product-list-search.component.d.ts +22 -0
- package/dist/types/modules/product-list/product-list-card.component.d.ts +30 -0
- package/dist/types/modules/product-list/product-list.commands.d.ts +62 -3
- package/dist/types/modules/product-list/product-list.component.d.ts +16 -43
- package/dist/types/{enums/cloud.enum.d.ts → modules/product-list/product-list.constants.d.ts} +20 -1
- package/dist/types/modules/product-list/product-list.interface.d.ts +33 -24
- 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 -1
- package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +13 -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/modal/modal.component.d.ts +23 -0
- package/dist/types/modules/ui-components/styles/modal.style.d.ts +1 -0
- package/dist/types/modules/ui-components/ui.commands.d.ts +3 -1
- package/dist/types/static/icon/check.icon.d.ts +2 -0
- package/dist/types/static/icon/index.d.ts +1 -0
- package/docs/gitbook/actions.md +160 -0
- package/docs/gitbook/address.md +48 -0
- package/docs/gitbook/cart.md +65 -0
- package/docs/gitbook/checkout.md +131 -0
- package/docs/gitbook/events.md +137 -0
- package/docs/gitbook/overview.md +166 -0
- package/docs/gitbook/product.md +64 -0
- package/docs/gitbook/quick-start-guide.md +393 -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 +387 -0
- package/docs/v1/api/actions/product-actions.md +115 -0
- package/docs/v1/api/client.md +482 -0
- package/docs/v1/api/configuration.md +1 -0
- package/docs/v1/api/injection-methods.md +247 -0
- package/docs/v1/api/typescript-types.md +1 -0
- package/docs/v1/api/ui-helpers.md +200 -0
- package/docs/v1/examples/advanced-patterns.md +96 -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 +324 -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 +191 -0
- package/docs/v1/guides/product-component.md +686 -0
- package/docs/v1/guides/product-list-component.md +598 -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 +60 -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 +34 -0
- package/docs/v1/reference/browser-support.md +35 -0
- package/docs/v1/reference/error-handling.md +70 -0
- package/docs/v1/reference/performance.md +54 -0
- package/docs/v1/reference/troubleshooting.md +64 -0
- package/package.json +19 -12
- package/dist/types/modules/product-list/components/product-list-card.component.d.ts +0 -37
- 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/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/{elements-builder-client.d.ts → clients/builder.d.ts} +0 -0
- /package/dist/types/{elements-client-helper.d.ts → clients/helpers.d.ts} +0 -0
- /package/dist/types/{elements-client.d.ts → clients/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.elements.ui.cartButton('header-cart');
|
|
27
|
+
|
|
28
|
+
// Cart button with item count badge
|
|
29
|
+
window.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.elements.ui.floatingCartButton();
|
|
55
|
+
|
|
56
|
+
// Floating button with badge
|
|
57
|
+
window.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.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.elements.ui.cartItemsCount('items-count', { hideZero: true });
|
|
118
|
+
|
|
119
|
+
// Always show count (even "0")
|
|
120
|
+
window.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.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.elements.ui.cartItemsCount('item-count');
|
|
155
|
+
window.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.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,96 @@
|
|
|
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.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
|
+
## Related Docs
|
|
92
|
+
|
|
93
|
+
- [Events Guide](../guides/events.md)
|
|
94
|
+
- [Product Component](../guides/product-component.md)
|
|
95
|
+
- [Checkout Component](../guides/checkout-component.md)
|
|
96
|
+
- [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://assets-elements.liquidcommerce.us/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://assets-elements.liquidcommerce.us/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.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://assets-elements.liquidcommerce.us/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://assets-elements.liquidcommerce.us/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)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Simple Product Page
|
|
2
|
+
|
|
3
|
+
A minimal, production-ready product page using the CDN build with a single Product component and the default cart drawer.
|
|
4
|
+
|
|
5
|
+
## What You'll Build
|
|
6
|
+
|
|
7
|
+
- One product component
|
|
8
|
+
- Optional cart button with item count
|
|
9
|
+
- Default cart and checkout flow
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
- LiquidCommerce API key
|
|
14
|
+
- One product identifier (UPC or grouping ID)
|
|
15
|
+
|
|
16
|
+
## HTML (CDN)
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<!DOCTYPE html>
|
|
20
|
+
<html lang="en">
|
|
21
|
+
<head>
|
|
22
|
+
<meta charset="UTF-8" />
|
|
23
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
24
|
+
<title>Simple Product Page</title>
|
|
25
|
+
|
|
26
|
+
<script
|
|
27
|
+
defer
|
|
28
|
+
data-liquid-commerce-elements
|
|
29
|
+
data-token="YOUR_API_KEY"
|
|
30
|
+
data-env="production"
|
|
31
|
+
data-container-1="product"
|
|
32
|
+
data-product-1="00619947000020"
|
|
33
|
+
data-cart-badge-button="header-cart"
|
|
34
|
+
type="text/javascript"
|
|
35
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
36
|
+
></script>
|
|
37
|
+
|
|
38
|
+
<style>
|
|
39
|
+
body {
|
|
40
|
+
font-family: Arial, sans-serif;
|
|
41
|
+
margin: 0;
|
|
42
|
+
padding: 0;
|
|
43
|
+
background: #f7f7f7;
|
|
44
|
+
}
|
|
45
|
+
header {
|
|
46
|
+
background: #fff;
|
|
47
|
+
padding: 16px 24px;
|
|
48
|
+
box-shadow: 0 2px 6px rgba(0,0,0,0.08);
|
|
49
|
+
display: flex;
|
|
50
|
+
justify-content: space-between;
|
|
51
|
+
align-items: center;
|
|
52
|
+
}
|
|
53
|
+
main {
|
|
54
|
+
max-width: 1100px;
|
|
55
|
+
margin: 24px auto;
|
|
56
|
+
padding: 0 24px;
|
|
57
|
+
}
|
|
58
|
+
#product {
|
|
59
|
+
background: #fff;
|
|
60
|
+
border-radius: 10px;
|
|
61
|
+
padding: 20px;
|
|
62
|
+
min-height: 600px;
|
|
63
|
+
}
|
|
64
|
+
</style>
|
|
65
|
+
</head>
|
|
66
|
+
<body>
|
|
67
|
+
<header>
|
|
68
|
+
<h1>Premium Spirits</h1>
|
|
69
|
+
<div id="header-cart"></div>
|
|
70
|
+
</header>
|
|
71
|
+
|
|
72
|
+
<main>
|
|
73
|
+
<div id="product"></div>
|
|
74
|
+
</main>
|
|
75
|
+
</body>
|
|
76
|
+
</html>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## What to Tweak Next
|
|
80
|
+
|
|
81
|
+
- Change the product identifier: `data-product-1="YOUR_PRODUCT_ID"`
|
|
82
|
+
- Add a second product (see [Multi-Product Page](./multi-product-page.md))
|
|
83
|
+
- Customize styling via theming (see [Theming Guide](../guides/theming.md))
|
|
84
|
+
|
|
85
|
+
## Related Docs
|
|
86
|
+
|
|
87
|
+
- [Product Component](../guides/product-component.md)
|
|
88
|
+
- [Cart Component](../guides/cart-component.md)
|
|
89
|
+
- [Quick Start](../getting-started/quick-start.md)
|