@liquidcommerce/elements-sdk 2.7.8 → 2.7.10
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 +1 -1
- package/dist/index.checkout.esm.js +6884 -6883
- package/dist/index.esm.js +11255 -11181
- package/dist/types/index.checkout.d.ts +1 -1
- package/dist/types/index.checkout.umd.d.ts +1 -1
- package/dist/types/interfaces/api/cart.interface.d.ts +1 -0
- package/dist/types/interfaces/api/checkout.interface.d.ts +1 -0
- package/dist/types/interfaces/api/product.interface.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-list/components/product-list-product-pre-cart.component.d.ts +3 -0
- package/dist/types/modules/product-list/product-list.component.d.ts +0 -1
- package/dist/types/modules/ui-components/engraving/engraving-view.component.d.ts +1 -0
- package/docs/v1/README.md +1 -1
- package/docs/v1/api/actions/checkout-actions.md +40 -0
- package/docs/v1/api/actions/product-actions.md +44 -1
- package/docs/v1/api/client.md +13 -0
- package/docs/v1/api/configuration.md +528 -1
- package/docs/v1/api/injection-methods.md +18 -4
- package/docs/v1/api/typescript-types.md +398 -1
- package/docs/v1/examples/advanced-patterns.md +102 -0
- package/docs/v1/examples/checkout-flow.md +2 -2
- package/docs/v1/examples/multi-product-page.md +2 -2
- package/docs/v1/examples/simple-product-page.md +1 -1
- package/docs/v1/getting-started/concepts.md +3 -3
- package/docs/v1/getting-started/installation.md +3 -3
- package/docs/v1/getting-started/quick-start.md +6 -6
- package/docs/v1/guides/address-component.md +1 -1
- package/docs/v1/guides/best-practices.md +29 -0
- package/docs/v1/guides/cart-component.md +7 -7
- package/docs/v1/guides/checkout-component.md +2 -2
- package/docs/v1/guides/product-component.md +5 -5
- package/docs/v1/guides/product-list-component.md +72 -163
- package/docs/v1/integration/laravel.md +1 -1
- package/docs/v1/integration/vanilla-js.md +2 -2
- package/docs/v1/reference/troubleshooting.md +64 -0
- package/package.json +14 -21
|
@@ -1 +1,398 @@
|
|
|
1
|
-
|
|
1
|
+
# TypeScript Types Reference
|
|
2
|
+
|
|
3
|
+
All public types are exported from the main package entry point. Import them using the `type` keyword for optimal tree-shaking.
|
|
4
|
+
|
|
5
|
+
## Importing Types
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
9
|
+
import type {
|
|
10
|
+
ILiquidCommerceElementsClient,
|
|
11
|
+
ILiquidCommerceElementsConfig,
|
|
12
|
+
IInjectProductElement,
|
|
13
|
+
IInjectedComponent
|
|
14
|
+
} from '@liquidcommerce/elements-sdk';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For the checkout-only build:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { ElementsCheckout } from '@liquidcommerce/elements-sdk/checkout';
|
|
21
|
+
import type {
|
|
22
|
+
IElementsCheckoutClient,
|
|
23
|
+
IElementsCheckoutActions,
|
|
24
|
+
ILiquidCommerceElementsCheckoutClientConfig,
|
|
25
|
+
IInjectedComponent
|
|
26
|
+
} from '@liquidcommerce/elements-sdk/checkout';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Client Types
|
|
32
|
+
|
|
33
|
+
### ILiquidCommerceElementsClient
|
|
34
|
+
|
|
35
|
+
Main SDK client interface returned by `Elements()`.
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
interface ILiquidCommerceElementsClient {
|
|
39
|
+
injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
|
|
40
|
+
injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
|
|
41
|
+
injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
|
|
42
|
+
injectCheckoutElement(params: IInjectCheckoutParams): Promise<IInjectedComponent | null>;
|
|
43
|
+
injectProductList(params: IInjectProductListParams): Promise<void>;
|
|
44
|
+
injectProductListSearch(params: IInjectProductListSearchParams): Promise<void>;
|
|
45
|
+
injectProductListFilters(params: IInjectProductListFiltersParams): Promise<void>;
|
|
46
|
+
ui: ILiquidCommerceElementsUIMethod;
|
|
47
|
+
actions: ILiquidCommerceElementsActions;
|
|
48
|
+
getInjectedComponents(): Map<string, IInjectedComponent>;
|
|
49
|
+
destroy(): void;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### ILiquidCommerceElementsBuilderClient
|
|
54
|
+
|
|
55
|
+
Builder-pattern client interface returned by `ElementsBuilder()`.
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
interface ILiquidCommerceElementsBuilderClient {
|
|
59
|
+
updateComponentGlobalConfigs(configs: UpdateComponentGlobalConfigs): Promise<void>;
|
|
60
|
+
updateProductComponent(configs: UpdateProductComponent): Promise<void>;
|
|
61
|
+
updateAddressComponent(configs: UpdateAddressComponent): void;
|
|
62
|
+
updateCartComponent(configs: UpdateCartComponent): void;
|
|
63
|
+
updateCheckoutComponent(configs: UpdateCheckoutComponent): void;
|
|
64
|
+
updateProductListComponent(configs: UpdateProductListComponent): void;
|
|
65
|
+
injectElement(params: IBuilderInjectElementParams): Promise<IInjectedComponent | null>;
|
|
66
|
+
injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
|
|
67
|
+
injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
|
|
68
|
+
injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
|
|
69
|
+
injectCheckoutElement(params: IInjectCheckoutBuilderParams): Promise<IInjectedComponent | null>;
|
|
70
|
+
injectProductList(params: IInjectProductListParams): Promise<void>;
|
|
71
|
+
actions: ILiquidCommerceElementsActions;
|
|
72
|
+
destroy(): void;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### IElementsCheckoutClient
|
|
77
|
+
|
|
78
|
+
Checkout-only client interface returned by `ElementsCheckout()`.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
interface IElementsCheckoutClient {
|
|
82
|
+
injectCheckout(params: IInjectCheckoutParams): Promise<IInjectedComponent | null>;
|
|
83
|
+
actions: { checkout: IElementsCheckoutActions };
|
|
84
|
+
destroy(): void;
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Configuration Types
|
|
91
|
+
|
|
92
|
+
### ILiquidCommerceElementsConfig
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
interface ILiquidCommerceElementsConfig {
|
|
96
|
+
env?: ElementsEnv;
|
|
97
|
+
promoTicker?: IPromoTicker[];
|
|
98
|
+
customTheme?: IClientCustomThemeConfig;
|
|
99
|
+
debugMode?: DebugMode;
|
|
100
|
+
checkout?: ILiquidCommerceElementsCheckoutConfig;
|
|
101
|
+
proxy?: IElementsProxyConfig;
|
|
102
|
+
development?: ILiquidCommerceElementsDevelopmentConfig;
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### ILiquidCommerceElementsCheckoutClientConfig
|
|
107
|
+
|
|
108
|
+
Same shape as `ILiquidCommerceElementsConfig`, used for the checkout-only client.
|
|
109
|
+
|
|
110
|
+
### IClientCustomThemeConfig
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
interface IClientCustomThemeConfig {
|
|
114
|
+
global?: UpdateComponentGlobalConfigs;
|
|
115
|
+
product?: UpdateProductComponent;
|
|
116
|
+
address?: UpdateAddressComponent;
|
|
117
|
+
cart?: UpdateCartComponent;
|
|
118
|
+
checkout?: UpdateCheckoutComponent;
|
|
119
|
+
productList?: UpdateProductListComponent;
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### IElementsProxyConfig
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
interface IElementsProxyConfig {
|
|
127
|
+
baseUrl: string;
|
|
128
|
+
headers?: Record<string, string>;
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### ILiquidCommerceElementsDevelopmentConfig
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
interface ILiquidCommerceElementsDevelopmentConfig {
|
|
136
|
+
customApiUrl?: string;
|
|
137
|
+
paymentMethodId?: string;
|
|
138
|
+
openShadowDom?: boolean;
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### ILiquidCommerceElementsCheckoutConfig
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
interface ILiquidCommerceElementsCheckoutConfig {
|
|
146
|
+
pageUrl?: string;
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
See [Configuration Reference](./configuration.md) for detailed property descriptions.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Injection Types
|
|
155
|
+
|
|
156
|
+
### IInjectProductElement
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
interface IInjectProductElement {
|
|
160
|
+
containerId: string;
|
|
161
|
+
identifier: string;
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### IInjectCheckoutParams
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
interface IInjectCheckoutParams {
|
|
169
|
+
containerId: string;
|
|
170
|
+
checkoutId?: string;
|
|
171
|
+
hideHeader?: boolean;
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### IInjectCheckoutBuilderParams
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
interface IInjectCheckoutBuilderParams extends IInjectCheckoutParams {
|
|
179
|
+
simulatePresale?: boolean;
|
|
180
|
+
presaleExpiresInMinutes?: number;
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### IInjectProductListParams
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
interface IInjectProductListParams {
|
|
188
|
+
containerId: string;
|
|
189
|
+
slug: string;
|
|
190
|
+
rows?: number;
|
|
191
|
+
columns?: number;
|
|
192
|
+
filters?: ProductListFilterType[];
|
|
193
|
+
productUrl?: string;
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### IInjectProductListSearchParams
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
interface IInjectProductListSearchParams {
|
|
201
|
+
containerId: string;
|
|
202
|
+
slug: string;
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### IInjectProductListFiltersParams
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
interface IInjectProductListFiltersParams {
|
|
210
|
+
containerId: string;
|
|
211
|
+
slug: string;
|
|
212
|
+
filters?: ProductListFilterType[];
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### IBuilderInjectElementParams
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
interface IBuilderInjectElementParams {
|
|
220
|
+
type: ComponentType;
|
|
221
|
+
containerId: string;
|
|
222
|
+
[key: string]: any;
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Component Types
|
|
229
|
+
|
|
230
|
+
### IInjectedComponent
|
|
231
|
+
|
|
232
|
+
Returned by all injection methods. Provides control over the injected component.
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
interface IInjectedComponent {
|
|
236
|
+
getType(): ComponentType;
|
|
237
|
+
getElement(): HTMLElement;
|
|
238
|
+
rerender(): void;
|
|
239
|
+
destroy(): void;
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## UI Types
|
|
246
|
+
|
|
247
|
+
### ILiquidCommerceElementsUIMethod
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
interface ILiquidCommerceElementsUIMethod {
|
|
251
|
+
cartButton(containerId: string, showItemsCount?: boolean): void;
|
|
252
|
+
floatingCartButton(showItemsCount?: boolean): void;
|
|
253
|
+
cartSubtotal(elementId: string): void;
|
|
254
|
+
cartItemsCount(elementId: string, options?: { hideZero: boolean }): void;
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Action Types
|
|
261
|
+
|
|
262
|
+
### ILiquidCommerceElementsActions
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
interface ILiquidCommerceElementsActions {
|
|
266
|
+
product: IProductActions;
|
|
267
|
+
address: IAddressActions;
|
|
268
|
+
cart: ICartActions;
|
|
269
|
+
checkout: ICheckoutActions;
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### IElementsCheckoutActions
|
|
274
|
+
|
|
275
|
+
Checkout actions available in the checkout-only client. Omits drawer-related methods.
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
interface IElementsCheckoutActions extends Omit<ICheckoutActions, 'openCheckout' | 'closeCheckout' | 'toggleCheckout'> {}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
See [Actions API](./actions/) for detailed method signatures.
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## Enum Types
|
|
286
|
+
|
|
287
|
+
### ElementsEnv
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
type ElementsEnv = 'development' | 'staging' | 'production';
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### DebugMode
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
type DebugMode = 'none' | 'console' | 'panel';
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### FulfillmentType
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
type FulfillmentType = 'onDemand' | 'shipping';
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### ComponentType
|
|
306
|
+
|
|
307
|
+
```typescript
|
|
308
|
+
type ComponentType =
|
|
309
|
+
| 'address' | 'product' | 'cart' | 'checkout'
|
|
310
|
+
| 'product-list' | 'product-list-card' | 'product-list-filters' | 'product-list-search'
|
|
311
|
+
| 'drawer' | 'input' | 'engraving-form' | 'engraving-view'
|
|
312
|
+
| 'buttons-cart-open' | 'powered-by' | 'lce-element'
|
|
313
|
+
| 'purchase-min-alert' | 'alert' | 'promo-code-ticker'
|
|
314
|
+
// ...and additional internal component types
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### DisplayModeType
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
type DisplayModeType = 'modal' | 'drawer';
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Theme Configuration Types
|
|
326
|
+
|
|
327
|
+
### UpdateComponentGlobalConfigs
|
|
328
|
+
|
|
329
|
+
`DeepPartial<IComponentGlobalConfigs>` -- all properties optional.
|
|
330
|
+
|
|
331
|
+
### UpdateProductComponent
|
|
332
|
+
|
|
333
|
+
`DeepPartial<IProductComponent>` -- all properties optional.
|
|
334
|
+
|
|
335
|
+
### UpdateCartComponent
|
|
336
|
+
|
|
337
|
+
`DeepPartial<ICartComponent>` -- all properties optional.
|
|
338
|
+
|
|
339
|
+
### UpdateCheckoutComponent
|
|
340
|
+
|
|
341
|
+
`DeepPartial<ICheckoutComponent>` -- all properties optional.
|
|
342
|
+
|
|
343
|
+
### UpdateAddressComponent
|
|
344
|
+
|
|
345
|
+
`DeepPartial<IAddressComponent>` -- all properties optional.
|
|
346
|
+
|
|
347
|
+
### UpdateProductListComponent
|
|
348
|
+
|
|
349
|
+
Special structure for updating product list configuration by slug:
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
interface UpdateProductListComponent {
|
|
353
|
+
theme?: { backgroundColor?: string };
|
|
354
|
+
layout?: {
|
|
355
|
+
lists?: Record<string, DeepPartial<IPLCList>>;
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
See [Configuration Reference](./configuration.md) for detailed theme property descriptions.
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Promo Ticker Type
|
|
365
|
+
|
|
366
|
+
### IPromoTicker
|
|
367
|
+
|
|
368
|
+
```typescript
|
|
369
|
+
interface IPromoTicker {
|
|
370
|
+
promoCode: string;
|
|
371
|
+
text: string[];
|
|
372
|
+
separator: string;
|
|
373
|
+
activeFrom: string; // ISO 8601 UTC
|
|
374
|
+
activeUntil: string; // ISO 8601 UTC
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## Utility Types
|
|
381
|
+
|
|
382
|
+
### DeepPartial
|
|
383
|
+
|
|
384
|
+
Used internally for theme update types. Makes all properties in `T` recursively optional.
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
type DeepPartial<T> = {
|
|
388
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
389
|
+
};
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## See Also
|
|
395
|
+
|
|
396
|
+
- [Client API](./client.md) - Client initialization and usage
|
|
397
|
+
- [Configuration Reference](./configuration.md) - Detailed config options
|
|
398
|
+
- [Injection Methods](./injection-methods.md) - Component injection API
|
|
@@ -88,6 +88,108 @@ const client = await Elements('YOUR_API_KEY', {
|
|
|
88
88
|
});
|
|
89
89
|
```
|
|
90
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
|
+
|
|
91
193
|
## Related Docs
|
|
92
194
|
|
|
93
195
|
- [Events Guide](../guides/events.md)
|
|
@@ -27,7 +27,7 @@ A two-page setup: a product page that adds to cart and redirects to a dedicated
|
|
|
27
27
|
data-cart-badge-button="header-cart"
|
|
28
28
|
data-checkout-url="https://yoursite.com/checkout?lce_checkout={token}"
|
|
29
29
|
type="text/javascript"
|
|
30
|
-
src="https://
|
|
30
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
31
31
|
></script>
|
|
32
32
|
</head>
|
|
33
33
|
<body>
|
|
@@ -63,7 +63,7 @@ When users click checkout, the cart redirects to your hosted checkout page with
|
|
|
63
63
|
data-checkout-container="checkout"
|
|
64
64
|
data-checkout-param="lce_checkout"
|
|
65
65
|
type="text/javascript"
|
|
66
|
-
src="https://
|
|
66
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
67
67
|
></script>
|
|
68
68
|
</head>
|
|
69
69
|
<body>
|
|
@@ -24,7 +24,7 @@ Show multiple products on a single page using declarative attributes or programm
|
|
|
24
24
|
data-container-3="product-3"
|
|
25
25
|
data-product-3="08068660001"
|
|
26
26
|
type="text/javascript"
|
|
27
|
-
src="https://
|
|
27
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
28
28
|
></script>
|
|
29
29
|
|
|
30
30
|
<style>
|
|
@@ -53,7 +53,7 @@ Show multiple products on a single page using declarative attributes or programm
|
|
|
53
53
|
data-token="YOUR_API_KEY"
|
|
54
54
|
data-env="production"
|
|
55
55
|
type="text/javascript"
|
|
56
|
-
src="https://
|
|
56
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
57
57
|
></script>
|
|
58
58
|
|
|
59
59
|
<script data-liquid-commerce-elements-products type="application/json">
|
|
@@ -32,7 +32,7 @@ A minimal, production-ready product page using the CDN build with a single Produ
|
|
|
32
32
|
data-product-1="00619947000020"
|
|
33
33
|
data-cart-badge-button="header-cart"
|
|
34
34
|
type="text/javascript"
|
|
35
|
-
src="https://
|
|
35
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
36
36
|
></script>
|
|
37
37
|
|
|
38
38
|
<style>
|
|
@@ -68,7 +68,7 @@ When using the CDN, the SDK auto-initializes on page load:
|
|
|
68
68
|
data-token="YOUR_API_KEY"
|
|
69
69
|
data-env="production"
|
|
70
70
|
type="text/javascript"
|
|
71
|
-
src="https://
|
|
71
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
72
72
|
></script>
|
|
73
73
|
```
|
|
74
74
|
|
|
@@ -135,7 +135,7 @@ Configure components using HTML data attributes:
|
|
|
135
135
|
data-container-1="product"
|
|
136
136
|
data-product-1="00619947000020"
|
|
137
137
|
type="text/javascript"
|
|
138
|
-
src="https://
|
|
138
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
139
139
|
></script>
|
|
140
140
|
|
|
141
141
|
<div id="product"></div>
|
|
@@ -187,7 +187,7 @@ You can use declarative initialization and programmatic control:
|
|
|
187
187
|
data-token="YOUR_API_KEY"
|
|
188
188
|
data-env="production"
|
|
189
189
|
type="text/javascript"
|
|
190
|
-
src="https://
|
|
190
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
191
191
|
></script>
|
|
192
192
|
|
|
193
193
|
<script>
|
|
@@ -26,7 +26,7 @@ Add the following script tag to your page's `<head>` section:
|
|
|
26
26
|
data-token="YOUR_API_KEY"
|
|
27
27
|
data-env="production"
|
|
28
28
|
type="text/javascript"
|
|
29
|
-
src="https://
|
|
29
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
30
30
|
></script>
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -55,7 +55,7 @@ While the `<head>` section is recommended, the script can be placed anywhere on
|
|
|
55
55
|
data-token="YOUR_API_KEY"
|
|
56
56
|
data-env="production"
|
|
57
57
|
type="text/javascript"
|
|
58
|
-
src="https://
|
|
58
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
59
59
|
></script>
|
|
60
60
|
</head>
|
|
61
61
|
<body>
|
|
@@ -77,7 +77,7 @@ If you only need checkout functionality (without product displays or cart), use
|
|
|
77
77
|
data-token="YOUR_API_KEY"
|
|
78
78
|
data-env="production"
|
|
79
79
|
type="text/javascript"
|
|
80
|
-
src="https://
|
|
80
|
+
src="https://elements.reservebar-worker.workers.dev/checkout/elements.js"
|
|
81
81
|
></script>
|
|
82
82
|
```
|
|
83
83
|
|
|
@@ -33,7 +33,7 @@ Add the Elements SDK script tag to your HTML `<head>`:
|
|
|
33
33
|
data-token="YOUR_API_KEY"
|
|
34
34
|
data-env="production"
|
|
35
35
|
type="text/javascript"
|
|
36
|
-
src="https://
|
|
36
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
37
37
|
></script>
|
|
38
38
|
</head>
|
|
39
39
|
<body>
|
|
@@ -70,7 +70,7 @@ Add product configuration using HTML data attributes on the script tag:
|
|
|
70
70
|
data-container-1="product-display"
|
|
71
71
|
data-product-1="00619947000020"
|
|
72
72
|
type="text/javascript"
|
|
73
|
-
src="https://
|
|
73
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
74
74
|
></script>
|
|
75
75
|
```
|
|
76
76
|
|
|
@@ -103,7 +103,7 @@ Here's the complete HTML for a working product page:
|
|
|
103
103
|
data-container-1="product-display"
|
|
104
104
|
data-product-1="00619947000020"
|
|
105
105
|
type="text/javascript"
|
|
106
|
-
src="https://
|
|
106
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
107
107
|
></script>
|
|
108
108
|
|
|
109
109
|
<style>
|
|
@@ -150,7 +150,7 @@ If you prefer JavaScript over HTML attributes:
|
|
|
150
150
|
data-token="YOUR_API_KEY"
|
|
151
151
|
data-env="production"
|
|
152
152
|
type="text/javascript"
|
|
153
|
-
src="https://
|
|
153
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
154
154
|
></script>
|
|
155
155
|
|
|
156
156
|
<script defer>
|
|
@@ -216,7 +216,7 @@ To display multiple products on one page:
|
|
|
216
216
|
data-product-3="08068660001"
|
|
217
217
|
|
|
218
218
|
type="text/javascript"
|
|
219
|
-
src="https://
|
|
219
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
220
220
|
></script>
|
|
221
221
|
|
|
222
222
|
<div id="product-1"></div>
|
|
@@ -347,7 +347,7 @@ Try this complete example with your API key:
|
|
|
347
347
|
data-container-1="product"
|
|
348
348
|
data-product-1="00619947000020"
|
|
349
349
|
type="text/javascript"
|
|
350
|
-
src="https://
|
|
350
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
351
351
|
></script>
|
|
352
352
|
|
|
353
353
|
<style>
|
|
@@ -200,7 +200,7 @@ Create a dedicated page for address selection:
|
|
|
200
200
|
data-token="YOUR_API_KEY"
|
|
201
201
|
data-env="production"
|
|
202
202
|
type="text/javascript"
|
|
203
|
-
src="https://
|
|
203
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
204
204
|
></script>
|
|
205
205
|
</head>
|
|
206
206
|
<body>
|