@liquidcommerce/elements-sdk 2.6.0-beta.40 → 2.6.0-beta.42

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.
Files changed (68) hide show
  1. package/README.md +79 -171
  2. package/dist/index.checkout.esm.js +6814 -6806
  3. package/dist/index.esm.js +10596 -10567
  4. package/dist/types/auto-initialize/shared-utils.d.ts +5 -0
  5. package/dist/types/core/base-component.service.d.ts +2 -1
  6. package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +1 -0
  7. package/dist/types/interfaces/core.interface.d.ts +5 -4
  8. package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
  9. package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
  10. package/dist/types/utils/dom-compat.d.ts +2 -0
  11. package/docs/gitbook/actions.md +964 -0
  12. package/docs/gitbook/address.md +48 -0
  13. package/docs/gitbook/cart.md +65 -0
  14. package/docs/gitbook/checkout.md +131 -0
  15. package/docs/gitbook/events.md +1765 -0
  16. package/docs/gitbook/overview.md +166 -0
  17. package/docs/gitbook/product.md +64 -0
  18. package/docs/gitbook/quick-start-guide.md +393 -0
  19. package/docs/v1/README.md +210 -0
  20. package/docs/v1/api/actions/address-actions.md +281 -0
  21. package/docs/v1/api/actions/cart-actions.md +337 -0
  22. package/docs/v1/api/actions/checkout-actions.md +387 -0
  23. package/docs/v1/api/actions/product-actions.md +115 -0
  24. package/docs/v1/api/client.md +482 -0
  25. package/docs/v1/api/configuration.md +1 -0
  26. package/docs/v1/api/injection-methods.md +247 -0
  27. package/docs/v1/api/typescript-types.md +1 -0
  28. package/docs/v1/api/ui-helpers.md +200 -0
  29. package/docs/v1/examples/advanced-patterns.md +96 -0
  30. package/docs/v1/examples/checkout-flow.md +91 -0
  31. package/docs/v1/examples/custom-theming.md +63 -0
  32. package/docs/v1/examples/multi-product-page.md +90 -0
  33. package/docs/v1/examples/simple-product-page.md +89 -0
  34. package/docs/v1/getting-started/concepts.md +507 -0
  35. package/docs/v1/getting-started/installation.md +328 -0
  36. package/docs/v1/getting-started/quick-start.md +405 -0
  37. package/docs/v1/guides/address-component.md +431 -0
  38. package/docs/v1/guides/best-practices.md +324 -0
  39. package/docs/v1/guides/cart-component.md +737 -0
  40. package/docs/v1/guides/checkout-component.md +672 -0
  41. package/docs/v1/guides/events.md +926 -0
  42. package/docs/v1/guides/product-component.md +686 -0
  43. package/docs/v1/guides/product-list-component.md +598 -0
  44. package/docs/v1/guides/theming.md +216 -0
  45. package/docs/v1/integration/angular.md +39 -0
  46. package/docs/v1/integration/laravel.md +41 -0
  47. package/docs/v1/integration/nextjs.md +60 -0
  48. package/docs/v1/integration/proxy-setup.md +89 -0
  49. package/docs/v1/integration/react.md +64 -0
  50. package/docs/v1/integration/vanilla-js.md +84 -0
  51. package/docs/v1/integration/vue.md +34 -0
  52. package/docs/v1/reference/browser-support.md +44 -0
  53. package/docs/v1/reference/error-handling.md +70 -0
  54. package/docs/v1/reference/performance.md +54 -0
  55. package/docs/v1/reference/troubleshooting.md +64 -0
  56. package/package.json +1 -1
  57. package/docs/actions.md +0 -320
  58. package/docs/address.md +0 -242
  59. package/docs/browser-support.md +0 -279
  60. package/docs/cart.md +0 -387
  61. package/docs/checkout.md +0 -420
  62. package/docs/configuration.md +0 -1017
  63. package/docs/events.md +0 -181
  64. package/docs/product-list.md +0 -311
  65. package/docs/product.md +0 -250
  66. package/docs/proxy.md +0 -228
  67. package/docs/theming.md +0 -682
  68. package/docs/troubleshooting.md +0 -793
@@ -1,1017 +0,0 @@
1
- # Configuration Reference
2
-
3
- Complete reference for all LiquidCommerce Elements SDK configuration options.
4
-
5
- ## Basic Configuration
6
-
7
- ```javascript
8
- const client = await Elements('YOUR_API_KEY', {
9
- env: 'production',
10
- debugMode: 'none',
11
- isBuilder: false,
12
- customTheme: {},
13
- proxy: {},
14
- promoTicker: [],
15
- checkout: {
16
- pageUrl: 'https://yoursite.com/checkout?id={id}' // Optional: hosted checkout
17
- }
18
- });
19
- ```
20
-
21
- ## Configuration Options
22
-
23
- ### `env` (required)
24
-
25
- **Type:** `'local' | 'development' | 'staging' | 'production'`
26
- **Default:** `'production'`
27
-
28
- Specifies the API environment to use.
29
-
30
- ```javascript
31
- env: 'production' // Live environment
32
- env: 'staging' // Pre-production testing
33
- env: 'development' // Development with extra logging
34
- env: 'local' // Local development
35
- ```
36
-
37
- **Environment URLs:**
38
- - `production`: `https://elements.liquidcommerce.us`
39
- - `staging`: `https://staging-elements.liquidcommerce.us`
40
- - `development`: `https://dev-elements.liquidcommerce.us`
41
- - `local`: `http://localhost:3000`
42
-
43
- ### `debugMode`
44
-
45
- **Type:** `'none' | 'console' | 'panel'`
46
- **Default:** `'none'`
47
-
48
- Controls logging and debugging output.
49
-
50
- ```javascript
51
- debugMode: 'none' // No logging (production)
52
- debugMode: 'console' // Console logs only
53
- debugMode: 'panel' // Visual debug panel + console
54
- ```
55
-
56
- **Debug panel features:**
57
- - Real-time event stream
58
- - API call inspector
59
- - State viewer
60
- - Performance metrics
61
-
62
- **Note:** Automatically disabled in production environment regardless of setting.
63
-
64
- ### `isBuilder`
65
-
66
- **Type:** `boolean`
67
- **Default:** `false`
68
-
69
- Enables builder mode for theme development and testing.
70
-
71
- ```javascript
72
- isBuilder: true // Enables builder.* methods
73
- ```
74
-
75
- **Builder mode provides:**
76
- - `client.builder.updateComponentGlobalConfigs()`
77
- - `client.builder.updateProductComponent()`
78
- - `client.builder.updateCartComponent()`
79
- - `client.builder.updateCheckoutComponent()`
80
- - `client.builder.updateAddressComponent()`
81
-
82
- **Use case:** Theme customization and testing.
83
-
84
- ### `customTheme`
85
-
86
- **Type:** `object`
87
- **Default:** `{}`
88
-
89
- Custom theme configuration. See [`theming.md`](./theming.md) for complete reference.
90
-
91
- ```javascript
92
- customTheme: {
93
- global: {
94
- colors: {
95
- primary: '#007bff',
96
- secondary: '#6c757d'
97
- },
98
- typography: {
99
- fontFamily: 'Inter, sans-serif',
100
- fontSize: '16px'
101
- },
102
- layout: {
103
- enablePersonalization: true,
104
- personalizationText: 'Personalize your product',
105
- personalizationCardStyle: 'outlined',
106
- allowPromoCodes: true,
107
- inputFieldStyle: 'outlined',
108
- poweredByMode: 'light' // Can be customized
109
- // Note: showPoweredBy cannot be customized (controlled by LiquidCommerce)
110
- }
111
- },
112
- product: { /* product theme */ },
113
- cart: { /* cart theme */ },
114
- checkout: { /* checkout theme */ },
115
- address: { /* address theme */ }
116
- }
117
- ```
118
-
119
- **Key Theme Categories:**
120
-
121
- - **`global`**: Affects all components (colors, fonts, personalization settings)
122
- - **`product`**: Product display customization
123
- - **`cart`**: Cart drawer and item display
124
- - **`checkout`**: Checkout flow and completion screen
125
- - **`address`**: Address input and selection
126
-
127
- **Personalization (Engraving) Settings:**
128
-
129
- The personalization feature is configured in `global.layout`:
130
-
131
- ```javascript
132
- customTheme: {
133
- global: {
134
- layout: {
135
- enablePersonalization: true, // Enable/disable engraving globally
136
- personalizationText: 'Make it yours', // Button text for adding personalization
137
- personalizationCardStyle: 'outlined' // Style: 'outlined' | 'filled'
138
- }
139
- }
140
- }
141
- ```
142
-
143
- - **`enablePersonalization`**: Master switch for engraving feature
144
- - **`personalizationText`**: Call-to-action text on product pages
145
- - **`personalizationCardStyle`**: Visual style in cart/checkout ('outlined' or 'filled')
146
- - **`poweredByMode`**: Visual mode for "Powered by" branding ('light' or 'dark')
147
-
148
- **Protected Setting:**
149
- ⚠️ **`showPoweredBy`** is a read-only setting controlled by LiquidCommerce. This paid feature cannot be customized through the `customTheme` configuration and is managed via your LiquidCommerce dashboard. However, you can customize `poweredByMode` to match your site's theme.
150
-
151
- ### `proxy`
152
-
153
- **Type:** `object`
154
- **Default:** `null`
155
-
156
- Proxy configuration for routing API requests through your server.
157
-
158
- ```javascript
159
- proxy: {
160
- baseUrl: 'https://yourdomain.com/api/liquidcommerce',
161
- headers: {
162
- 'X-Custom-Header': 'value'
163
- }
164
- }
165
- ```
166
-
167
- **Properties:**
168
-
169
- #### `proxy.baseUrl`
170
-
171
- **Type:** `string` (required)
172
-
173
- Base URL for your proxy endpoint.
174
-
175
- ```javascript
176
- baseUrl: 'https://yourdomain.com/api/liquidcommerce'
177
- ```
178
-
179
- The SDK automatically appends API paths: `/api/products`, `/api/cart`, etc.
180
-
181
- #### `proxy.headers`
182
-
183
- **Type:** `object` (optional)
184
-
185
- Custom headers to include in proxied requests.
186
-
187
- ```javascript
188
- headers: {
189
- 'X-Custom-Auth': 'your-token',
190
- 'X-Request-Id': 'unique-id'
191
- }
192
- ```
193
-
194
- See [`proxy.md`](./proxy.md) for implementation guide.
195
-
196
- ### `promoTicker`
197
-
198
- **Type:** `array`
199
- **Default:** `[]`
200
-
201
- Promotional ticker configuration for rotating messages.
202
-
203
- ```javascript
204
- promoTicker: [
205
- {
206
- promoCode: 'FREESHIP',
207
- text: ['Free Shipping Today!', 'Use code FREESHIP'],
208
- separator: '•',
209
- activeFrom: '2025-01-01T00:00:00Z',
210
- activeUntil: '2025-12-31T23:59:59Z'
211
- }
212
- ]
213
- ```
214
-
215
- **Properties:**
216
-
217
- #### `promoCode` (required)
218
-
219
- **Type:** `string`
220
-
221
- The promo code to apply when clicked.
222
-
223
- #### `text` (required)
224
-
225
- **Type:** `string[]`
226
-
227
- Array of messages to rotate through.
228
-
229
- ```javascript
230
- text: ['Message 1', 'Message 2', 'Message 3']
231
- ```
232
-
233
- #### `separator` (optional)
234
-
235
- **Type:** `string`
236
- **Default:** `'•'`
237
-
238
- Separator between rotating messages.
239
-
240
- ```javascript
241
- separator: '•' // Bullet
242
- separator: '|' // Pipe
243
- separator: '→' // Arrow
244
- ```
245
-
246
- #### `activeFrom` (optional)
247
-
248
- **Type:** `string` (ISO 8601)
249
-
250
- Start date/time for the promotion.
251
-
252
- ```javascript
253
- activeFrom: '2025-01-01T00:00:00Z'
254
- ```
255
-
256
- #### `activeUntil` (optional)
257
-
258
- **Type:** `string` (ISO 8601)
259
-
260
- End date/time for the promotion.
261
-
262
- ```javascript
263
- activeUntil: '2025-12-31T23:59:59Z'
264
- ```
265
-
266
- **Note:** Only active promotions are displayed.
267
-
268
- ### `checkout`
269
-
270
- **Type:** `object`
271
- **Default:** `undefined`
272
-
273
- Configuration for hosted checkout (external checkout page).
274
-
275
- ```javascript
276
- checkout: {
277
- pageUrl: 'https://yoursite.com/checkout?id={id}'
278
- }
279
- ```
280
-
281
- **Properties:**
282
-
283
- #### `checkout.pageUrl`
284
-
285
- **Type:** `string` (required)
286
-
287
- URL of your dedicated checkout page. The `{id}` placeholder is replaced with the checkout token.
288
-
289
- ```javascript
290
- pageUrl: 'https://yoursite.com/checkout?id={id}'
291
- ```
292
-
293
- When set, the "Go to Checkout" button in the cart redirects to this URL instead of opening the checkout drawer.
294
-
295
- ## Auto-Initialization Configuration
296
-
297
- When using auto-initialization, configure via `data-` attributes on the script tag.
298
-
299
- ### Required Attributes
300
-
301
- ```html
302
- <script
303
- defer
304
- type="text/javascript"
305
- data-liquid-commerce-elements
306
- data-token="YOUR_API_KEY"
307
- src="https://assets-elements.liquidcommerce.us/all/elements.js"
308
- ></script>
309
- ```
310
-
311
- #### `data-liquid-commerce-elements`
312
-
313
- **Type:** flag (no value)
314
-
315
- Enables auto-initialization.
316
-
317
- #### `data-token`
318
-
319
- **Type:** `string` (required)
320
-
321
- Your LiquidCommerce API key.
322
-
323
- ### Optional Attributes
324
-
325
- #### `data-env`
326
-
327
- **Type:** `'production' | 'staging' | 'development' | 'local'`
328
- **Default:** `'production'`
329
-
330
- ```html
331
- data-env="production"
332
- ```
333
-
334
- #### `data-debug-mode`
335
-
336
- **Type:** `'console' | 'panel'`
337
- **Default:** Not set
338
-
339
- ```html
340
- data-debug-mode="console"
341
- ```
342
-
343
- #### `data-cart-button`
344
-
345
- **Type:** `string`
346
-
347
- Container ID, CSS selector, or position-prefixed selector for simple cart button (no badge).
348
-
349
- ```html
350
- <!-- Simple ID (with or without # prefix) -->
351
- data-cart-button="header-cart" <!-- Works with or without # -->
352
- data-cart-button="#header-cart" <!-- Also works with # prefix -->
353
-
354
- <!-- CSS Selector (from browser inspect tool) -->
355
- data-cart-button=".header .nav-links"
356
- data-cart-button="#main-navigation"
357
-
358
- <!-- Position-prefixed selectors -->
359
- data-cart-button="above:.header .logo" <!-- Place above the target -->
360
- data-cart-button="below:#main-navigation" <!-- Place below the target -->
361
- data-cart-button="below:main-navigation" <!-- Also works without # prefix -->
362
- data-cart-button="replace:.old-cart" <!-- Replace the target -->
363
- data-cart-button="inside:.header .nav" <!-- Place inside the target (default) -->
364
-
365
- <!-- Floating cart button (no badge) -->
366
- data-cart-button="" <!-- Empty value = floating button -->
367
- ```
368
-
369
- **Smart Fallback Behavior:**
370
- - If the target element is not found, automatically falls back to floating cart button
371
- - If attribute is present but empty (`data-cart-button=""`), creates floating cart button without badge
372
- - Element IDs are automatically prefixed with `#` if needed (e.g., `header-cart` becomes `#header-cart`)
373
-
374
- #### `data-cart-badge-button`
375
-
376
- **Type:** `string`
377
-
378
- Container ID, CSS selector, or position-prefixed selector for cart button with item count badge.
379
-
380
- ```html
381
- <!-- Simple ID (with or without # prefix) -->
382
- data-cart-badge-button="header-cart" <!-- Works with or without # -->
383
- data-cart-badge-button="#header-cart" <!-- Also works with # prefix -->
384
-
385
- <!-- CSS Selector (from browser inspect tool) -->
386
- data-cart-badge-button=".header .nav-links"
387
- data-cart-badge-button="#main-navigation"
388
-
389
- <!-- Position-prefixed selectors -->
390
- data-cart-badge-button="above:.header .logo" <!-- Place above the target -->
391
- data-cart-badge-button="below:#main-navigation" <!-- Place below the target -->
392
- data-cart-badge-button="replace:.old-cart" <!-- Replace the target -->
393
- data-cart-badge-button="inside:.header .nav" <!-- Place inside the target (default) -->
394
-
395
- <!-- Floating cart button with badge (default) -->
396
- data-cart-badge-button="" <!-- Empty value = floating button with badge -->
397
- ```
398
-
399
- **Smart Fallback Behavior:**
400
- - If the target element is not found, automatically falls back to floating cart button with badge
401
- - If attribute is present but empty (`data-cart-badge-button=""`), creates floating cart button with badge
402
- - Element IDs are automatically prefixed with `#` if needed
403
- - If neither `data-cart-button` nor `data-cart-badge-button` is provided, defaults to floating cart button with badge
404
-
405
- **Position Prefixes:**
406
- - `above:` - Place above the target element
407
- - `below:` - Place below the target element
408
- - `replace:` - Replace the target element
409
- - `inside:` - Place inside the target element (default)
410
-
411
- #### `data-cart-mobile-button`
412
-
413
- **Type:** `string`
414
-
415
- Mobile-specific cart button (no badge). Same syntax as `data-cart-button` but only shown on mobile devices.
416
-
417
- ```html
418
- data-cart-mobile-button="below:.mobile-header"
419
- data-cart-mobile-button="inside:.mobile-nav"
420
- ```
421
-
422
- #### `data-cart-mobile-badge-button`
423
-
424
- **Type:** `string`
425
-
426
- Mobile-specific cart button with item count badge. Same syntax as `data-cart-badge-button` but only shown on mobile devices.
427
-
428
- ```html
429
- data-cart-mobile-badge-button="below:.mobile-header"
430
- data-cart-mobile-badge-button="inside:.mobile-nav"
431
- ```
432
-
433
- #### `data-cart-button-hidden`
434
-
435
- **Type:** flag (no value)
436
-
437
- Hide cart button completely. Use this when you want to manage cart display manually via `client.actions.cart.openCart()`.
438
-
439
- ```html
440
- data-cart-button-hidden
441
- ```
442
-
443
- **Important:** When this attribute is present, the SDK will skip all cart button setup, including floating buttons. This takes precedence over `data-cart-button` and `data-cart-badge-button` attributes.
444
-
445
- ### Cart Button Examples
446
-
447
- **Simple cart button (no badge):**
448
- ```html
449
- <script
450
- defer
451
- type="text/javascript"
452
- data-liquid-commerce-elements
453
- data-token="your-api-key"
454
- data-cart-button="header-cart"
455
- src="elements.js">
456
- </script>
457
- ```
458
-
459
- **Cart button with item count badge:**
460
- ```html
461
- <script
462
- defer
463
- type="text/javascript"
464
- data-liquid-commerce-elements
465
- data-token="your-api-key"
466
- data-cart-badge-button="header-cart"
467
- src="elements.js">
468
- </script>
469
- ```
470
-
471
- **Using position-prefixed selectors:**
472
- ```html
473
- <!-- Place inside the target element (default) -->
474
- <script
475
- defer
476
- type="text/javascript"
477
- data-liquid-commerce-elements
478
- data-token="your-api-key"
479
- data-cart-badge-button="inside:.header .nav-links"
480
- src="elements.js">
481
- </script>
482
-
483
- <!-- Place above the target element -->
484
- <script
485
- defer
486
- type="text/javascript"
487
- data-liquid-commerce-elements
488
- data-token="your-api-key"
489
- data-cart-button="above:.header .logo"
490
- src="elements.js">
491
- </script>
492
-
493
- <!-- Place below the target element -->
494
- <script
495
- defer
496
- type="text/javascript"
497
- data-liquid-commerce-elements
498
- data-token="your-api-key"
499
- data-cart-badge-button="below:#main-navigation"
500
- src="elements.js">
501
- </script>
502
-
503
- <!-- Replace the target element -->
504
- <script
505
- defer
506
- type="text/javascript"
507
- data-liquid-commerce-elements
508
- data-token="your-api-key"
509
- data-cart-button="replace:.old-cart-button"
510
- src="elements.js">
511
- </script>
512
- ```
513
-
514
- **No cart button:**
515
- ```html
516
- <script
517
- defer
518
- type="text/javascript"
519
- data-liquid-commerce-elements
520
- data-token="your-api-key"
521
- data-cart-button-hidden
522
- src="elements.js">
523
- </script>
524
- ```
525
-
526
- **Default behavior (floating cart button with badge):**
527
- ```html
528
- <script
529
- defer
530
- type="text/javascript"
531
- data-liquid-commerce-elements
532
- data-token="your-api-key"
533
- src="elements.js">
534
- </script>
535
- ```
536
-
537
- ### Getting CSS Selectors from Browser
538
-
539
- **Super Easy Method:**
540
- 1. **Right-click** on any element where you want the cart button
541
- 2. Select **"Inspect"** or **"Inspect Element"**
542
- 3. In developer tools, **right-click** on the highlighted element
543
- 4. Select **"Copy" → "Copy selector"**
544
- 5. Paste the selector into your `data-cart-button` or `data-cart-badge-button` attribute
545
-
546
- **Example:**
547
- ```html
548
- <!-- After copying selector from browser inspect tool -->
549
- <script
550
- data-liquid-commerce-elements
551
- data-token="your-api-key"
552
- data-cart-badge-button="body > div.container > header > nav > div.nav-links"
553
- src="elements.js">
554
- </script>
555
- ```
556
-
557
- ### Product Configuration
558
-
559
- #### Method 1: Direct Attributes
560
-
561
- ```html
562
- data-container-1="product-1"
563
- data-product-1="00619947000020"
564
- data-container-2="product-2"
565
- data-product-2="00832889005513"
566
- ```
567
-
568
- #### Method 2: JSON Configuration
569
-
570
- ```html
571
- <script data-liquid-commerce-elements-products type="application/json">
572
- [
573
- { "containerId": "product-1", "identifier": "00619947000020" },
574
- { "containerId": "product-2", "identifier": "00832889005513" }
575
- ]
576
- </script>
577
- ```
578
-
579
- #### Method 3: Annotated Elements
580
-
581
- ```html
582
- <div data-lce-product="00619947000020"></div>
583
- <div data-lce-product="00832889005513"></div>
584
- ```
585
-
586
- ### Product List Configuration
587
-
588
- ```html
589
- <div data-liquid-commerce-elements-products-list
590
- data-rows="3"
591
- data-columns="4"
592
- data-filters="engraving,presale,fulfillment,price,brands"
593
- data-product-url="/product/{upc}">
594
- </div>
595
- ```
596
-
597
- **Attributes:**
598
-
599
- ##### `data-liquid-commerce-elements-products-list`
600
-
601
- **Type:** flag (no value)
602
-
603
- Enables product list on this div element.
604
-
605
- ##### `data-rows`
606
-
607
- **Type:** `number`
608
- **Default:** `3`
609
-
610
- Number of rows to display per page (1-10).
611
-
612
- ```html
613
- data-rows="4"
614
- ```
615
-
616
- ##### `data-columns`
617
-
618
- **Type:** `number`
619
- **Default:** `4`
620
-
621
- Number of columns in the grid (1-4).
622
-
623
- ```html
624
- data-columns="4"
625
- ```
626
-
627
- ##### `data-filters`
628
-
629
- **Type:** `string` (comma-separated)
630
-
631
- Filter types to enable.
632
-
633
- ```html
634
- data-filters="engraving,presale,fulfillment,price,brands"
635
- ```
636
-
637
- **Available filters:**
638
- - `engraving` - Show filter for personalized/engravable products
639
- - `presale` - Show filter for pre-order products
640
- - `fulfillment` - Show filter for delivery type (shipping, onDemand)
641
- - `price` - Show price range filter
642
- - `brands` - Show brand filter
643
- - `categories` - Show category filter
644
- - `flavor` - Show flavor filter
645
- - `region` - Show region filter
646
- - `variety` - Show variety filter
647
- - `vintage` - Show vintage year filter
648
- - `country` - Show country filter
649
- - `appellation` - Show appellation filter
650
- - `materials` - Show materials filter
651
- - `sizes` - Show size filter
652
-
653
- ##### `data-product-url`
654
-
655
- **Type:** `string`
656
-
657
- Product detail page URL template. Use `{upc}` or `{grouping}` placeholder.
658
-
659
- ```html
660
- data-product-url="/product/{upc}"
661
- data-product-url="/products/{grouping}"
662
- ```
663
-
664
- **Placeholders:**
665
- - `{upc}` - Replaced with product UPC
666
- - `{grouping}` - Replaced with Salsify grouping ID
667
-
668
- ### Product List Search and Filters Containers
669
-
670
- You can place search and filter components in separate containers:
671
-
672
- ```html
673
- <!-- Search bar (any div) -->
674
- <div data-search-container></div>
675
-
676
- <!-- Filter panel (any div) -->
677
- <div data-filters-container></div>
678
- ```
679
-
680
- These work alongside the main `data-liquid-commerce-elements-products-list` container. The search and filter components communicate with the product list automatically.
681
-
682
- ### Checkout URL Configuration
683
-
684
- #### `data-checkout-url`
685
-
686
- **Type:** `string`
687
-
688
- URL for hosted checkout page. The `{id}` placeholder is replaced with the checkout token.
689
-
690
- ```html
691
- data-checkout-url="https://yoursite.com/checkout?id={id}"
692
- ```
693
-
694
- When set, the "Go to Checkout" button in the cart redirects to this URL instead of opening the checkout drawer.
695
-
696
- ### Custom Cart Elements
697
-
698
- #### `data-lce-cart-toggle-button`
699
-
700
- **Type:** flag (no value)
701
-
702
- Add to any element to make it toggle the cart open/closed on click.
703
-
704
- ```html
705
- <button data-lce-cart-toggle-button>Open Cart</button>
706
- ```
707
-
708
- #### `data-lce-cart-items-count`
709
-
710
- **Type:** `string` (optional value: `"keep-zero"`)
711
-
712
- Displays the current cart item count inside the element. Updated automatically.
713
-
714
- ```html
715
- <!-- Hides when count is 0 -->
716
- <span data-lce-cart-items-count></span>
717
-
718
- <!-- Always shows count, even when 0 -->
719
- <span data-lce-cart-items-count="keep-zero">0</span>
720
- ```
721
-
722
- ### URL Parameter Configuration
723
-
724
- #### `data-product-param`
725
-
726
- **Type:** `string`
727
-
728
- URL parameter name for auto-adding products to cart.
729
-
730
- ```html
731
- data-product-param="lce_product"
732
- ```
733
-
734
- **Usage:** `?lce_product=00619947000020&lce_fulfillment=shipping`
735
-
736
- #### `data-product-fulfillment-type-param`
737
-
738
- **Type:** `string`
739
-
740
- URL parameter name for fulfillment type.
741
-
742
- ```html
743
- data-product-fulfillment-type-param="lce_fulfillment"
744
- ```
745
-
746
- **Values:** `shipping` or `onDemand`
747
-
748
- #### `data-promo-code-param`
749
-
750
- **Type:** `string`
751
-
752
- URL parameter name for auto-applying promo codes.
753
-
754
- ```html
755
- data-promo-code-param="lce_promo"
756
- ```
757
-
758
- **Usage:** `?lce_promo=SUMMER20`
759
-
760
- ### Promo Ticker Configuration
761
-
762
- #### `data-promo-code`
763
-
764
- **Type:** `string`
765
-
766
- Promo code to apply.
767
-
768
- ```html
769
- data-promo-code="FREESHIP"
770
- ```
771
-
772
- #### `data-promo-text`
773
-
774
- **Type:** `string` (pipe-separated)
775
-
776
- Messages to display.
777
-
778
- ```html
779
- data-promo-text="Free Shipping Today!|Use code FREESHIP"
780
- ```
781
-
782
- #### `data-promo-separator`
783
-
784
- **Type:** `string`
785
- **Default:** `'•'`
786
-
787
- ```html
788
- data-promo-separator="•"
789
- ```
790
-
791
- #### `data-promo-active-from`
792
-
793
- **Type:** `string` (ISO 8601)
794
-
795
- ```html
796
- data-promo-active-from="2025-01-01T00:00:00Z"
797
- ```
798
-
799
- #### `data-promo-active-until`
800
-
801
- **Type:** `string` (ISO 8601)
802
-
803
- ```html
804
- data-promo-active-until="2025-12-31T23:59:59Z"
805
- ```
806
-
807
- ## Checkout-Only Build (Hosted Checkout)
808
-
809
- For hosted checkout pages, use the checkout-only build for a smaller bundle.
810
-
811
- ### Auto-Initialization
812
-
813
- ```html
814
- <script
815
- defer
816
- type="text/javascript"
817
- data-liquid-commerce-checkout
818
- data-token="YOUR_API_KEY"
819
- data-env="production"
820
- data-debug-mode="none"
821
- src="https://assets-elements.liquidcommerce.us/checkout/elements.js"
822
- ></script>
823
- ```
824
-
825
- **Attributes:**
826
- - `data-liquid-commerce-checkout` - Enables checkout-only auto-initialization (required)
827
- - `data-token` - Your API key (required)
828
- - `data-env` - Environment: `production`, `staging`, `development`
829
- - `data-debug-mode` - Debug mode: `console`, `panel`
830
- - `data-checkout-url` - Checkout page URL (for redirect behavior)
831
-
832
- ### Programmatic Initialization
833
-
834
- ```javascript
835
- import { ElementsCheckout } from '@liquidcommerce/elements-sdk/checkout';
836
-
837
- const client = await ElementsCheckout('YOUR_API_KEY', {
838
- env: 'production'
839
- });
840
-
841
- const component = await client.injectCheckout({
842
- containerId: 'checkout-container',
843
- checkoutId: 'checkout-token-from-url', // Optional: checkout token
844
- hideHeader: true // Optional
845
- });
846
- ```
847
-
848
- **Differences from full SDK:**
849
- - Smaller bundle (tree-shaken, no product/cart/PLP components)
850
- - Only `injectCheckout()` method available (no `injectProductElement`, `injectCartElement`, etc.)
851
- - Checkout actions only (no `openCheckout`/`closeCheckout`/`toggleCheckout` drawer controls)
852
- - Same theming, events, and configuration system
853
-
854
- ## TypeScript Types
855
-
856
- ### `ILiquidCommerceElementsConfig`
857
-
858
- ```typescript
859
- interface ILiquidCommerceElementsConfig {
860
- env?: 'local' | 'development' | 'staging' | 'production';
861
- debugMode?: 'none' | 'console' | 'panel';
862
- isBuilder?: boolean;
863
- customTheme?: IClientCustomThemeConfig;
864
- proxy?: IElementsProxyConfig;
865
- promoTicker?: IPromoTicker[];
866
- checkout?: ILiquidCommerceElementsCheckoutConfig;
867
- }
868
-
869
- interface ILiquidCommerceElementsCheckoutConfig {
870
- pageUrl: string; // URL with {id} placeholder for checkout token
871
- }
872
- ```
873
-
874
- ### `IElementsProxyConfig`
875
-
876
- ```typescript
877
- interface IElementsProxyConfig {
878
- baseUrl: string;
879
- headers?: Record<string, string>;
880
- }
881
- ```
882
-
883
- ### `IPromoTicker`
884
-
885
- ```typescript
886
- interface IPromoTicker {
887
- promoCode: string;
888
- text: string[];
889
- separator: string;
890
- activeFrom: string; // ISO 8601 UTC format
891
- activeUntil: string; // ISO 8601 UTC format
892
- }
893
- ```
894
-
895
- ## Configuration Examples
896
-
897
- ### Production Setup
898
-
899
- ```javascript
900
- const client = await Elements('YOUR_PRODUCTION_API_KEY', {
901
- env: 'production',
902
- debugMode: 'none',
903
- proxy: {
904
- baseUrl: 'https://yourdomain.com/api/liquidcommerce'
905
- },
906
- customTheme: {
907
- global: {
908
- colors: {
909
- primary: '#007bff'
910
- }
911
- }
912
- }
913
- });
914
- ```
915
-
916
- ### Development Setup
917
-
918
- ```javascript
919
- const client = await Elements('YOUR_DEV_API_KEY', {
920
- env: 'development',
921
- debugMode: 'panel',
922
- isBuilder: true,
923
- customTheme: {
924
- global: {
925
- colors: {
926
- primary: '#ff6b6b'
927
- }
928
- }
929
- }
930
- });
931
- ```
932
-
933
- ### With Promo Ticker
934
-
935
- ```javascript
936
- const client = await Elements('YOUR_API_KEY', {
937
- env: 'production',
938
- promoTicker: [
939
- {
940
- promoCode: 'SUMMER20',
941
- text: ['20% Off Summer Sale!', 'Use code SUMMER20'],
942
- separator: '•',
943
- activeFrom: '2025-06-01T00:00:00Z',
944
- activeUntil: '2025-08-31T23:59:59Z'
945
- }
946
- ]
947
- });
948
- ```
949
-
950
- ## Configuration Validation
951
-
952
- The SDK validates configuration on initialization:
953
-
954
- ```javascript
955
- try {
956
- const client = await Elements('YOUR_API_KEY', {
957
- env: 'invalid' // ❌ Will throw error
958
- });
959
- } catch (error) {
960
- console.error('Invalid configuration:', error);
961
- }
962
- ```
963
-
964
- **Common validation errors:**
965
- - Invalid environment value
966
- - Missing API key
967
- - Invalid proxy baseUrl
968
- - Malformed promo ticker dates
969
-
970
- ## Environment Variables
971
-
972
- For framework integrations, use environment variables:
973
-
974
- ### React / Next.js
975
-
976
- ```javascript
977
- const client = await Elements(process.env.REACT_APP_LCE_API_KEY, {
978
- env: process.env.REACT_APP_LCE_ENV || 'production'
979
- });
980
- ```
981
-
982
- ### Vue
983
-
984
- ```javascript
985
- const client = await Elements(process.env.VUE_APP_LCE_API_KEY, {
986
- env: process.env.VUE_APP_LCE_ENV || 'production'
987
- });
988
- ```
989
-
990
- ### Node.js / Server-Side
991
-
992
- ```javascript
993
- const client = await Elements(process.env.LCE_API_KEY, {
994
- env: process.env.NODE_ENV === 'production' ? 'production' : 'development'
995
- });
996
- ```
997
-
998
- ## Configuration Best Practices
999
-
1000
- 1. **Use environment variables** for API keys (never hardcode)
1001
- 2. **Enable debug mode only in development** (security risk in production)
1002
- 3. **Pin to specific version** in production for stability
1003
- 4. **Configure proxy** if targeting ad blocker-heavy audiences
1004
- 5. **Use minimal theme overrides** for optimal performance
1005
- 6. **Set GTM container ID** for analytics tracking
1006
- 7. **Test configuration** in staging before production
1007
- 8. **Validate promo dates** to avoid expired promotions
1008
- 9. **Use builder mode** only in development (performance overhead)
1009
- 10. **Monitor proxy** health if using custom proxy
1010
-
1011
- ## Related Documentation
1012
-
1013
- - [Theming Guide](./theming.md) - Complete theme configuration reference
1014
- - [Proxy Setup](./proxy.md) - Proxy implementation guide
1015
- - [Actions Reference](./actions.md) - Programmatic control API
1016
- - [Events Reference](./events.md) - Event system and tracking
1017
-