@liquidcommerce/elements-sdk 2.6.0-beta.37 → 2.6.0-beta.39

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.
@@ -11,7 +11,10 @@ const client = await Elements('YOUR_API_KEY', {
11
11
  isBuilder: false,
12
12
  customTheme: {},
13
13
  proxy: {},
14
- promoTicker: []
14
+ promoTicker: [],
15
+ checkout: {
16
+ pageUrl: 'https://yoursite.com/checkout?id={id}' // Optional: hosted checkout
17
+ }
15
18
  });
16
19
  ```
17
20
 
@@ -83,7 +86,7 @@ isBuilder: true // Enables builder.* methods
83
86
  **Type:** `object`
84
87
  **Default:** `{}`
85
88
 
86
- Custom theme configuration. See [`THEMING.md`](./THEMING.md) for complete reference.
89
+ Custom theme configuration. See [`theming.md`](./theming.md) for complete reference.
87
90
 
88
91
  ```javascript
89
92
  customTheme: {
@@ -188,7 +191,7 @@ headers: {
188
191
  }
189
192
  ```
190
193
 
191
- See [`PROXY.md`](./PROXY.md) for implementation guide.
194
+ See [`proxy.md`](./proxy.md) for implementation guide.
192
195
 
193
196
  ### `promoTicker`
194
197
 
@@ -262,6 +265,33 @@ activeUntil: '2025-12-31T23:59:59Z'
262
265
 
263
266
  **Note:** Only active promotions are displayed.
264
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
+
265
295
  ## Auto-Initialization Configuration
266
296
 
267
297
  When using auto-initialization, configure via `data-` attributes on the script tag.
@@ -270,6 +300,8 @@ When using auto-initialization, configure via `data-` attributes on the script t
270
300
 
271
301
  ```html
272
302
  <script
303
+ defer
304
+ type="text/javascript"
273
305
  data-liquid-commerce-elements
274
306
  data-token="YOUR_API_KEY"
275
307
  src="https://assets-elements.liquidcommerce.us/all/elements.js"
@@ -376,6 +408,28 @@ data-cart-badge-button="" <!-- Empty value = floating button w
376
408
  - `replace:` - Replace the target element
377
409
  - `inside:` - Place inside the target element (default)
378
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
+
379
433
  #### `data-cart-button-hidden`
380
434
 
381
435
  **Type:** flag (no value)
@@ -392,7 +446,9 @@ data-cart-button-hidden
392
446
 
393
447
  **Simple cart button (no badge):**
394
448
  ```html
395
- <script
449
+ <script
450
+ defer
451
+ type="text/javascript"
396
452
  data-liquid-commerce-elements
397
453
  data-token="your-api-key"
398
454
  data-cart-button="header-cart"
@@ -402,7 +458,9 @@ data-cart-button-hidden
402
458
 
403
459
  **Cart button with item count badge:**
404
460
  ```html
405
- <script
461
+ <script
462
+ defer
463
+ type="text/javascript"
406
464
  data-liquid-commerce-elements
407
465
  data-token="your-api-key"
408
466
  data-cart-badge-button="header-cart"
@@ -413,7 +471,9 @@ data-cart-button-hidden
413
471
  **Using position-prefixed selectors:**
414
472
  ```html
415
473
  <!-- Place inside the target element (default) -->
416
- <script
474
+ <script
475
+ defer
476
+ type="text/javascript"
417
477
  data-liquid-commerce-elements
418
478
  data-token="your-api-key"
419
479
  data-cart-badge-button="inside:.header .nav-links"
@@ -421,7 +481,9 @@ data-cart-button-hidden
421
481
  </script>
422
482
 
423
483
  <!-- Place above the target element -->
424
- <script
484
+ <script
485
+ defer
486
+ type="text/javascript"
425
487
  data-liquid-commerce-elements
426
488
  data-token="your-api-key"
427
489
  data-cart-button="above:.header .logo"
@@ -429,7 +491,9 @@ data-cart-button-hidden
429
491
  </script>
430
492
 
431
493
  <!-- Place below the target element -->
432
- <script
494
+ <script
495
+ defer
496
+ type="text/javascript"
433
497
  data-liquid-commerce-elements
434
498
  data-token="your-api-key"
435
499
  data-cart-badge-button="below:#main-navigation"
@@ -437,7 +501,9 @@ data-cart-button-hidden
437
501
  </script>
438
502
 
439
503
  <!-- Replace the target element -->
440
- <script
504
+ <script
505
+ defer
506
+ type="text/javascript"
441
507
  data-liquid-commerce-elements
442
508
  data-token="your-api-key"
443
509
  data-cart-button="replace:.old-cart-button"
@@ -447,7 +513,9 @@ data-cart-button-hidden
447
513
 
448
514
  **No cart button:**
449
515
  ```html
450
- <script
516
+ <script
517
+ defer
518
+ type="text/javascript"
451
519
  data-liquid-commerce-elements
452
520
  data-token="your-api-key"
453
521
  data-cart-button-hidden
@@ -457,7 +525,9 @@ data-cart-button-hidden
457
525
 
458
526
  **Default behavior (floating cart button with badge):**
459
527
  ```html
460
- <script
528
+ <script
529
+ defer
530
+ type="text/javascript"
461
531
  data-liquid-commerce-elements
462
532
  data-token="your-api-key"
463
533
  src="elements.js">
@@ -517,11 +587,9 @@ data-product-2="00832889005513"
517
587
 
518
588
  ```html
519
589
  <div data-liquid-commerce-elements-products-list
520
- data-card="standard"
521
590
  data-rows="3"
522
591
  data-columns="4"
523
- data-card-fill
524
- data-filters="personalization,pre-order,delivery-options"
592
+ data-filters="engraving,presale,fulfillment,price,brands"
525
593
  data-product-url="/product/{upc}">
526
594
  </div>
527
595
  ```
@@ -534,23 +602,12 @@ data-product-2="00832889005513"
534
602
 
535
603
  Enables product list on this div element.
536
604
 
537
- ##### `data-card`
538
-
539
- **Type:** `'standard'`
540
- **Default:** `'standard'`
541
-
542
- Card variant style.
543
-
544
- ```html
545
- data-card="standard"
546
- ```
547
-
548
605
  ##### `data-rows`
549
606
 
550
- **Type:** `number`
607
+ **Type:** `number`
551
608
  **Default:** `3`
552
609
 
553
- Number of rows to display per page.
610
+ Number of rows to display per page (1-10).
554
611
 
555
612
  ```html
556
613
  data-rows="4"
@@ -558,39 +615,40 @@ data-rows="4"
558
615
 
559
616
  ##### `data-columns`
560
617
 
561
- **Type:** `number`
618
+ **Type:** `number`
562
619
  **Default:** `4`
563
620
 
564
- Number of columns in the grid.
621
+ Number of columns in the grid (1-4).
565
622
 
566
623
  ```html
567
624
  data-columns="4"
568
625
  ```
569
626
 
570
- ##### `data-card-fill`
571
-
572
- **Type:** flag (no value)
573
-
574
- Whether cards should fill the whole card with white background color to match the image background color.
575
-
576
- ```html
577
- data-card-fill
578
- ```
579
-
580
627
  ##### `data-filters`
581
628
 
582
629
  **Type:** `string` (comma-separated)
583
630
 
584
- Filter types to enable: `personalization`, `pre-order`, `delivery-options`.
631
+ Filter types to enable.
585
632
 
586
633
  ```html
587
- data-filters="personalization,pre-order,delivery-options"
634
+ data-filters="engraving,presale,fulfillment,price,brands"
588
635
  ```
589
636
 
590
637
  **Available filters:**
591
- - `personalization` - Show filter for personalized/engravable products
592
- - `pre-order` - Show filter for pre-order products
593
- - `delivery-options` - Show filter for delivery type (all, shipping, onDemand)
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
594
652
 
595
653
  ##### `data-product-url`
596
654
 
@@ -607,6 +665,60 @@ data-product-url="/products/{grouping}"
607
665
  - `{upc}` - Replaced with product UPC
608
666
  - `{grouping}` - Replaced with Salsify grouping ID
609
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
+
610
722
  ### URL Parameter Configuration
611
723
 
612
724
  #### `data-product-param`
@@ -692,6 +804,53 @@ data-promo-active-from="2025-01-01T00:00:00Z"
692
804
  data-promo-active-until="2025-12-31T23:59:59Z"
693
805
  ```
694
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
+
695
854
  ## TypeScript Types
696
855
 
697
856
  ### `ILiquidCommerceElementsConfig`
@@ -704,6 +863,11 @@ interface ILiquidCommerceElementsConfig {
704
863
  customTheme?: IClientCustomThemeConfig;
705
864
  proxy?: IElementsProxyConfig;
706
865
  promoTicker?: IPromoTicker[];
866
+ checkout?: ILiquidCommerceElementsCheckoutConfig;
867
+ }
868
+
869
+ interface ILiquidCommerceElementsCheckoutConfig {
870
+ pageUrl: string; // URL with {id} placeholder for checkout token
707
871
  }
708
872
  ```
709
873
 
@@ -846,8 +1010,8 @@ const client = await Elements(process.env.LCE_API_KEY, {
846
1010
 
847
1011
  ## Related Documentation
848
1012
 
849
- - [Theming Guide](./THEMING.md) - Complete theme configuration reference
850
- - [Proxy Setup](./PROXY.md) - Proxy implementation guide
851
- - [Actions Reference](./ACTIONS.md) - Programmatic control API
852
- - [Events Reference](./EVENTS.md) - Event system and tracking
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
853
1017
 
package/docs/events.md ADDED
@@ -0,0 +1,181 @@
1
+ # Events
2
+
3
+ Events tell you what's happening in real-time: when products load, items get added to cart, checkout completes, and more. Use them to trigger analytics, show custom notifications, sync with your backend, or build reactive UI.
4
+
5
+ ## Subscribing to Events
6
+
7
+ ```javascript
8
+ window.addEventListener('lce:actions.EVENT_NAME', (event) => {
9
+ const data = event.detail.data;
10
+ const metadata = event.detail.metadata;
11
+ });
12
+ ```
13
+
14
+ ### Event Metadata
15
+
16
+ Every event includes metadata:
17
+
18
+ ```javascript
19
+ {
20
+ eventId: string, // Unique event ID
21
+ namespace: 'actions', // Event namespace
22
+ event: string, // Event name
23
+ originalEvent: string, // Full namespaced event
24
+ actionNamespace?: string, // 'address' | 'product' | 'cart' | 'checkout'
25
+ timestamp: number // Unix timestamp
26
+ }
27
+ ```
28
+
29
+ ---
30
+
31
+ ## Lifecycle Events
32
+
33
+ | Event | Description |
34
+ |-------|-------------|
35
+ | `client_ready` | SDK initialized and ready to use |
36
+
37
+ ---
38
+
39
+ ## Product Events
40
+
41
+ | Event | Description |
42
+ |-------|-------------|
43
+ | `product_loaded` | Product data fetched and displayed |
44
+ | `product_add_to_cart` | Customer added product to cart |
45
+ | `product_quantity_increase` | Quantity increased on product |
46
+ | `product_quantity_decrease` | Quantity decreased on product |
47
+ | `product_size_changed` | Size/variant selection changed |
48
+ | `product_fulfillment_type_changed` | Shipping/on-demand type changed |
49
+ | `product_fulfillment_changed` | Specific retailer/fulfillment changed |
50
+
51
+ ---
52
+
53
+ ## Address Events
54
+
55
+ | Event | Description |
56
+ |-------|-------------|
57
+ | `address_updated` | Delivery location set or changed |
58
+ | `address_cleared` | Delivery location removed |
59
+ | `address_failed` | Address operation failed |
60
+
61
+ ---
62
+
63
+ ## Cart Events
64
+
65
+ | Event | Description |
66
+ |-------|-------------|
67
+ | `cart_loaded` | Cart data fetched and ready |
68
+ | `cart_opened` | Cart drawer opened |
69
+ | `cart_closed` | Cart drawer closed |
70
+ | `cart_updated` | Cart items or totals changed |
71
+ | `cart_reset` | Cart cleared completely |
72
+ | `cart_failed` | Cart operation failed |
73
+ | `cart_item_added` | Item added to cart |
74
+ | `cart_item_removed` | Item removed from cart |
75
+ | `cart_item_quantity_increase` | Item quantity increased |
76
+ | `cart_item_quantity_decrease` | Item quantity decreased |
77
+ | `cart_item_engraving_updated` | Personalization added/changed/removed |
78
+ | `cart_product_add_success` | Programmatic add succeeded |
79
+ | `cart_product_add_failed` | Programmatic add failed |
80
+ | `cart_promo_code_applied` | Discount code applied |
81
+ | `cart_promo_code_removed` | Discount code removed |
82
+ | `cart_promo_code_failed` | Discount code rejected |
83
+
84
+ ---
85
+
86
+ ## Checkout Events
87
+
88
+ ### Lifecycle
89
+
90
+ | Event | Description |
91
+ |-------|-------------|
92
+ | `checkout_loaded` | Checkout ready |
93
+ | `checkout_opened` | Checkout drawer opened |
94
+ | `checkout_closed` | Checkout drawer closed |
95
+ | `checkout_failed` | Checkout operation failed |
96
+
97
+ ### Submit
98
+
99
+ | Event | Description |
100
+ |-------|-------------|
101
+ | `checkout_submit_started` | Payment processing started |
102
+ | `checkout_submit_completed` | Order successfully placed |
103
+ | `checkout_submit_failed` | Order submission failed |
104
+
105
+ ### Form Updates
106
+
107
+ | Event | Description |
108
+ |-------|-------------|
109
+ | `checkout_customer_information_updated` | Customer form completed |
110
+ | `checkout_billing_information_updated` | Billing form completed |
111
+ | `checkout_gift_information_updated` | Gift form completed |
112
+ | `checkout_is_gift_toggled` | Gift option toggled |
113
+ | `checkout_billing_same_as_shipping_toggled` | Billing address option toggled |
114
+ | `checkout_marketing_preferences_toggled` | Email/SMS opt-in toggled |
115
+
116
+ ### Item Changes
117
+
118
+ | Event | Description |
119
+ |-------|-------------|
120
+ | `checkout_item_removed` | Item removed from checkout |
121
+ | `checkout_item_quantity_increase` | Item quantity increased |
122
+ | `checkout_item_quantity_decrease` | Item quantity decreased |
123
+ | `checkout_item_engraving_updated` | Personalization changed |
124
+ | `checkout_tip_updated` | Delivery tip changed |
125
+
126
+ ### Discounts
127
+
128
+ | Event | Description |
129
+ |-------|-------------|
130
+ | `checkout_product_add_success` | Programmatic add succeeded |
131
+ | `checkout_product_add_failed` | Programmatic add failed |
132
+ | `checkout_promo_code_applied` | Discount applied |
133
+ | `checkout_promo_code_removed` | Discount removed |
134
+ | `checkout_promo_code_failed` | Discount rejected |
135
+ | `checkout_gift_card_applied` | Gift card applied |
136
+ | `checkout_gift_card_removed` | Gift card removed |
137
+ | `checkout_gift_card_failed` | Gift card rejected |
138
+
139
+ ---
140
+
141
+ ## Listening to All Events
142
+
143
+ Catch all action events with a namespace listener:
144
+
145
+ ```javascript
146
+ // All action events
147
+ window.addEventListener('lce:actions', (event) => {
148
+ const eventName = event.detail.metadata.event;
149
+ console.log('Event fired:', eventName);
150
+ });
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Security Notes
156
+
157
+ Events are designed with security in mind:
158
+
159
+ **Included in events:**
160
+ - Success/failure status
161
+ - Discount amounts (visible in UI)
162
+ - Total amounts (visible in UI)
163
+ - Item counts and identifiers
164
+
165
+ **Never included:**
166
+ - Promo codes or gift card codes
167
+ - Gift card balances
168
+ - Customer names, emails, addresses
169
+ - Payment information
170
+
171
+ Form update events (like `checkout_customer_information_updated`) only indicate completion, not actual customer data.
172
+
173
+ ---
174
+
175
+ ## See Also
176
+
177
+ - [Actions Reference](./actions.md) - Programmatic control
178
+ - [Product](./product.md) - Product component
179
+ - [Cart](./cart.md) - Cart component
180
+ - [Checkout](./checkout.md) - Checkout component
181
+ - [Address](./address.md) - Address component