@liquidcommerce/elements-sdk 2.7.0 → 2.7.2
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 -2750
- package/dist/index.checkout.esm.js +6898 -6837
- package/dist/index.esm.js +11463 -10993
- package/dist/types/auto-initialize/shared-utils.d.ts +5 -0
- package/dist/types/constants/core.constant.d.ts +0 -4
- package/dist/types/core/base-component.service.d.ts +2 -1
- package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +1 -0
- package/dist/types/enums/core.enum.d.ts +11 -0
- package/dist/types/interfaces/configs/product-list.interface.d.ts +2 -2
- package/dist/types/interfaces/core.interface.d.ts +5 -4
- package/dist/types/modules/address/address-input.component.d.ts +11 -0
- package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
- package/dist/types/modules/product-list/components/card-components/index.d.ts +3 -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-fulfillments.d.ts +2 -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-title.d.ts +6 -0
- package/dist/types/modules/product-list/components/index.d.ts +1 -0
- package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +5 -1
- 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 +10 -2
- package/dist/types/modules/product-list/product-list-card.component.d.ts +0 -5
- package/dist/types/modules/product-list/product-list.commands.d.ts +11 -2
- package/dist/types/modules/product-list/product-list.interface.d.ts +1 -0
- package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +11 -2
- package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
- package/dist/types/utils/dom-compat.d.ts +2 -0
- package/docs/gitbook/actions.md +964 -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 +1765 -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 +926 -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 +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 +64 -0
- package/package.json +1 -1
- package/docs/ACTIONS.md +0 -1301
- package/docs/BROWSER_SUPPORT.md +0 -279
- package/docs/CONFIGURATION.md +0 -997
- package/docs/DOCUMENTATION_INDEX.md +0 -319
- package/docs/EVENTS.md +0 -798
- package/docs/PROXY.md +0 -228
- package/docs/THEMING.md +0 -681
- package/docs/TROUBLESHOOTING.md +0 -793
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# Injection Methods API
|
|
2
|
+
|
|
3
|
+
Methods for injecting SDK components into your page.
|
|
4
|
+
|
|
5
|
+
## injectProductElement()
|
|
6
|
+
|
|
7
|
+
Inject one or more product displays.
|
|
8
|
+
|
|
9
|
+
### Signature
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Parameters
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
interface IInjectProductElement {
|
|
19
|
+
containerId: string; // ID of container element
|
|
20
|
+
identifier: string; // Product Identifier
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Example
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
await client.injectProductElement([
|
|
28
|
+
{ containerId: 'product-1', identifier: '00619947000020' },
|
|
29
|
+
{ containerId: 'product-2', identifier: '08504405135' }
|
|
30
|
+
]);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Returns
|
|
34
|
+
|
|
35
|
+
Array of injected component objects.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## injectAddressElement()
|
|
40
|
+
|
|
41
|
+
Inject standalone address component.
|
|
42
|
+
|
|
43
|
+
### Signature
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
injectAddressElement(
|
|
47
|
+
containerId: string,
|
|
48
|
+
options?: IAddressOptions
|
|
49
|
+
): Promise<IInjectedComponent | null>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Example
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
await client.injectAddressElement('address-container', {
|
|
56
|
+
onAddressSet: (address) => {
|
|
57
|
+
console.log('Address set:', address);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## injectCartElement()
|
|
65
|
+
|
|
66
|
+
Inject standalone cart (rarely needed - cart drawer is automatic).
|
|
67
|
+
|
|
68
|
+
### Signature
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
injectCartElement(containerId: string): Promise<IInjectedComponent | null>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Example
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
await client.injectCartElement('cart-container');
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## injectCheckoutElement()
|
|
83
|
+
|
|
84
|
+
Inject hosted checkout page.
|
|
85
|
+
|
|
86
|
+
### Signature
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
injectCheckoutElement(params: IInjectCheckoutParams): Promise<IInjectedComponent | null>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Parameters
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
interface IInjectCheckoutParams {
|
|
96
|
+
containerId: string;
|
|
97
|
+
checkoutId?: string; // Optional checkout token to load
|
|
98
|
+
hideHeader?: boolean; // Hide checkout header
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Example
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
await client.injectCheckoutElement({
|
|
106
|
+
containerId: 'checkout',
|
|
107
|
+
checkoutId: 'cart_abc123',
|
|
108
|
+
hideHeader: false
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## injectProductList()
|
|
115
|
+
|
|
116
|
+
Inject product catalog/listing.
|
|
117
|
+
|
|
118
|
+
### Signature
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
injectProductList(params: IInjectProductListParams): Promise<void>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Parameters
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
interface IInjectProductListParams {
|
|
128
|
+
containerId: string;
|
|
129
|
+
rows?: number; // Default: 3
|
|
130
|
+
columns?: number; // Default: 4
|
|
131
|
+
filters?: ProductListFilterType[];
|
|
132
|
+
productUrl?: string; // URL pattern with {identifier}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Example
|
|
137
|
+
|
|
138
|
+
```javascript
|
|
139
|
+
await client.injectProductList({
|
|
140
|
+
containerId: 'products',
|
|
141
|
+
rows: 4,
|
|
142
|
+
columns: 3,
|
|
143
|
+
filters: ['price', 'brand', 'category'],
|
|
144
|
+
productUrl: '/product/{identifier}'
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## injectProductListSearch()
|
|
151
|
+
|
|
152
|
+
Inject product search box.
|
|
153
|
+
|
|
154
|
+
### Signature
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
injectProductListSearch(params: IInjectProductListSearchParams): Promise<void>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Parameters
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
interface IInjectProductListSearchParams {
|
|
164
|
+
containerId: string;
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Example
|
|
169
|
+
|
|
170
|
+
```javascript
|
|
171
|
+
await client.injectProductListSearch({
|
|
172
|
+
containerId: 'search-box'
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## injectProductListFilters()
|
|
179
|
+
|
|
180
|
+
Inject product filter panel.
|
|
181
|
+
|
|
182
|
+
### Signature
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
injectProductListFilters(params: IInjectProductListFiltersParams): Promise<void>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Parameters
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
interface IInjectProductListFiltersParams {
|
|
192
|
+
containerId: string;
|
|
193
|
+
filters: ProductListFilterType[];
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Example
|
|
198
|
+
|
|
199
|
+
```javascript
|
|
200
|
+
await client.injectProductListFilters({
|
|
201
|
+
containerId: 'filters',
|
|
202
|
+
filters: ['price', 'brand', 'fulfillment']
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Component Management
|
|
209
|
+
|
|
210
|
+
### getInjectedComponents()
|
|
211
|
+
|
|
212
|
+
Retrieve all injected components.
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
getInjectedComponents(): Map<string, IInjectedComponent>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
```javascript
|
|
219
|
+
const components = client.getInjectedComponents();
|
|
220
|
+
|
|
221
|
+
// Get specific component
|
|
222
|
+
const product = components.get('product-1');
|
|
223
|
+
|
|
224
|
+
// Rerender component
|
|
225
|
+
product.rerender();
|
|
226
|
+
|
|
227
|
+
// Get container element
|
|
228
|
+
const container = product.getElement();
|
|
229
|
+
|
|
230
|
+
// Get component type
|
|
231
|
+
const type = product.getType(); // 'product'
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### IInjectedComponent Interface
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
interface IInjectedComponent {
|
|
238
|
+
getType(): ComponentType;
|
|
239
|
+
getElement(): HTMLElement;
|
|
240
|
+
rerender(): void;
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## See Also
|
|
245
|
+
|
|
246
|
+
- [Client API](./client.md)
|
|
247
|
+
- [Component Guides](../guides/)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
to be created...
|
|
@@ -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)
|