@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.
Files changed (81) hide show
  1. package/README.md +83 -2750
  2. package/dist/index.checkout.esm.js +6898 -6837
  3. package/dist/index.esm.js +11463 -10993
  4. package/dist/types/auto-initialize/shared-utils.d.ts +5 -0
  5. package/dist/types/constants/core.constant.d.ts +0 -4
  6. package/dist/types/core/base-component.service.d.ts +2 -1
  7. package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +1 -0
  8. package/dist/types/enums/core.enum.d.ts +11 -0
  9. package/dist/types/interfaces/configs/product-list.interface.d.ts +2 -2
  10. package/dist/types/interfaces/core.interface.d.ts +5 -4
  11. package/dist/types/modules/address/address-input.component.d.ts +11 -0
  12. package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
  13. package/dist/types/modules/product-list/components/card-components/index.d.ts +3 -0
  14. package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +8 -0
  15. package/dist/types/modules/product-list/components/card-components/product-fulfillments.d.ts +2 -0
  16. package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +13 -0
  17. package/dist/types/modules/product-list/components/card-components/product-title.d.ts +6 -0
  18. package/dist/types/modules/product-list/components/index.d.ts +1 -0
  19. package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +5 -1
  20. package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +28 -0
  21. package/dist/types/modules/product-list/components/product-list-retailers.component.d.ts +10 -2
  22. package/dist/types/modules/product-list/product-list-card.component.d.ts +0 -5
  23. package/dist/types/modules/product-list/product-list.commands.d.ts +11 -2
  24. package/dist/types/modules/product-list/product-list.interface.d.ts +1 -0
  25. package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +11 -2
  26. package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
  27. package/dist/types/utils/dom-compat.d.ts +2 -0
  28. package/docs/gitbook/actions.md +964 -0
  29. package/docs/gitbook/address.md +48 -0
  30. package/docs/gitbook/cart.md +65 -0
  31. package/docs/gitbook/checkout.md +131 -0
  32. package/docs/gitbook/events.md +1765 -0
  33. package/docs/gitbook/overview.md +166 -0
  34. package/docs/gitbook/product.md +64 -0
  35. package/docs/gitbook/quick-start-guide.md +393 -0
  36. package/docs/v1/README.md +210 -0
  37. package/docs/v1/api/actions/address-actions.md +281 -0
  38. package/docs/v1/api/actions/cart-actions.md +337 -0
  39. package/docs/v1/api/actions/checkout-actions.md +387 -0
  40. package/docs/v1/api/actions/product-actions.md +115 -0
  41. package/docs/v1/api/client.md +482 -0
  42. package/docs/v1/api/configuration.md +1 -0
  43. package/docs/v1/api/injection-methods.md +247 -0
  44. package/docs/v1/api/typescript-types.md +1 -0
  45. package/docs/v1/api/ui-helpers.md +200 -0
  46. package/docs/v1/examples/advanced-patterns.md +96 -0
  47. package/docs/v1/examples/checkout-flow.md +91 -0
  48. package/docs/v1/examples/custom-theming.md +63 -0
  49. package/docs/v1/examples/multi-product-page.md +90 -0
  50. package/docs/v1/examples/simple-product-page.md +89 -0
  51. package/docs/v1/getting-started/concepts.md +507 -0
  52. package/docs/v1/getting-started/installation.md +328 -0
  53. package/docs/v1/getting-started/quick-start.md +405 -0
  54. package/docs/v1/guides/address-component.md +431 -0
  55. package/docs/v1/guides/best-practices.md +324 -0
  56. package/docs/v1/guides/cart-component.md +737 -0
  57. package/docs/v1/guides/checkout-component.md +672 -0
  58. package/docs/v1/guides/events.md +926 -0
  59. package/docs/v1/guides/product-component.md +686 -0
  60. package/docs/v1/guides/product-list-component.md +598 -0
  61. package/docs/v1/guides/theming.md +216 -0
  62. package/docs/v1/integration/angular.md +39 -0
  63. package/docs/v1/integration/laravel.md +41 -0
  64. package/docs/v1/integration/nextjs.md +60 -0
  65. package/docs/v1/integration/proxy-setup.md +89 -0
  66. package/docs/v1/integration/react.md +64 -0
  67. package/docs/v1/integration/vanilla-js.md +84 -0
  68. package/docs/v1/integration/vue.md +34 -0
  69. package/docs/v1/reference/browser-support.md +44 -0
  70. package/docs/v1/reference/error-handling.md +70 -0
  71. package/docs/v1/reference/performance.md +54 -0
  72. package/docs/v1/reference/troubleshooting.md +64 -0
  73. package/package.json +1 -1
  74. package/docs/ACTIONS.md +0 -1301
  75. package/docs/BROWSER_SUPPORT.md +0 -279
  76. package/docs/CONFIGURATION.md +0 -997
  77. package/docs/DOCUMENTATION_INDEX.md +0 -319
  78. package/docs/EVENTS.md +0 -798
  79. package/docs/PROXY.md +0 -228
  80. package/docs/THEMING.md +0 -681
  81. package/docs/TROUBLESHOOTING.md +0 -793
@@ -0,0 +1,926 @@
1
+ # Events Guide
2
+
3
+ The SDK publishes browser events for user interactions and state changes. Use them to react to product selections, cart updates, and checkout progress.
4
+
5
+ ## Event Format
6
+
7
+ All SDK events are dispatched as native `CustomEvent` objects. The payload lives in `event.detail`:
8
+
9
+ ```javascript
10
+ window.addEventListener('lce:actions.client_ready', (event) => {
11
+ const { data, metadata } = event.detail;
12
+
13
+ const {
14
+ event: eventName,
15
+ namespace,
16
+ originalEvent,
17
+ actionNamespace,
18
+ eventId,
19
+ timestamp
20
+ } = metadata;
21
+ });
22
+ ```
23
+
24
+ `data` is event-specific. `metadata` describes the event (name, namespace, timestamp, etc).
25
+
26
+ ## Event Namespaces
27
+
28
+ - `lce:actions.*` - User actions and state changes
29
+ - `lce:forms.*` - Form field interactions (checkout)
30
+ - `lce:actions` - All action events (namespace-level listener)
31
+ - `lce:forms` - All form events (namespace-level listener)
32
+
33
+ Example: listen to every action event:
34
+
35
+ ```javascript
36
+ window.addEventListener('lce:actions', (event) => {
37
+ const { metadata } = event.detail;
38
+ console.log('Action event:', metadata.event);
39
+ });
40
+ ```
41
+
42
+ ## Core Events
43
+
44
+ ### `lce:actions.client_ready`
45
+
46
+ Fires once when the SDK finishes initializing and is ready for actions.
47
+
48
+ **Data includes:** `isReady`, `message`, `timestamp`, `version`.
49
+
50
+ **Example**
51
+
52
+ ```javascript
53
+ window.addEventListener('lce:actions.client_ready', (event) => {
54
+ const { data } = event.detail;
55
+ if (data.isReady) {
56
+ console.log('Elements SDK ready', data.version);
57
+ }
58
+ });
59
+ ```
60
+
61
+ ## Product Events
62
+
63
+ ### `lce:actions.product_loaded`
64
+
65
+ Fires when a product component finishes loading and product data is available.
66
+
67
+ **Data includes:** `identifier`, `name`, `price`, `selectedSizeId`, `selectedFulfillmentType`.
68
+
69
+ **Example**
70
+
71
+ ```javascript
72
+ window.addEventListener('lce:actions.product_loaded', (event) => {
73
+ const { data } = event.detail;
74
+ console.log(`Loaded ${data.name} (${data.identifier})`);
75
+ });
76
+ ```
77
+
78
+ ### `lce:actions.product_add_to_cart`
79
+
80
+ Fires when the user triggers add-to-cart from a product component. Use cart events to confirm success or failure.
81
+
82
+ **Data includes:** `identifier`, `quantity`, `fulfillmentId`, `partNumber`, `engravingLines`.
83
+
84
+ **Example**
85
+
86
+ ```javascript
87
+ window.addEventListener('lce:actions.product_add_to_cart', (event) => {
88
+ const { data } = event.detail;
89
+ gtag('event', 'add_to_cart_click', { item_id: data.identifier, quantity: data.quantity });
90
+ });
91
+ ```
92
+
93
+ ### `lce:actions.product_size_changed`
94
+
95
+ Fires when the user changes the selected size.
96
+
97
+ **Data includes:** `identifier`, `selectedSizeId`, `selectedSize`, `previousSizeId`, `previousSize`.
98
+
99
+ **Example**
100
+
101
+ ```javascript
102
+ window.addEventListener('lce:actions.product_size_changed', (event) => {
103
+ const { data } = event.detail;
104
+ console.log(`Size changed to ${data.selectedSize}`);
105
+ });
106
+ ```
107
+
108
+ ### `lce:actions.product_fulfillment_type_changed`
109
+
110
+ Fires when the user switches between fulfillment types (for example shipping vs onDemand).
111
+
112
+ **Data includes:** `identifier`, `selectedFulfillmentType`, `previousFulfillmentType`, `selectedFulfillmentId`, `previousFulfillmentId`.
113
+
114
+ **Example**
115
+
116
+ ```javascript
117
+ window.addEventListener('lce:actions.product_fulfillment_type_changed', (event) => {
118
+ const { data } = event.detail;
119
+ console.log('Fulfillment type:', data.selectedFulfillmentType);
120
+ });
121
+ ```
122
+
123
+ ### `lce:actions.product_fulfillment_changed`
124
+
125
+ Fires when the user selects a different fulfillment option or retailer.
126
+
127
+ **Data includes:** `identifier`, `selectedFulfillmentId`, `previousFulfillmentId`, `selectedFulfillmentType`, `previousFulfillmentType`.
128
+
129
+ **Example**
130
+
131
+ ```javascript
132
+ window.addEventListener('lce:actions.product_fulfillment_changed', (event) => {
133
+ const { data } = event.detail;
134
+ console.log('Fulfillment changed:', data.selectedFulfillmentId);
135
+ });
136
+ ```
137
+
138
+ ### `lce:actions.product_quantity_increase`
139
+
140
+ Fires when the product quantity is increased.
141
+
142
+ **Data includes:** `identifier`, `quantity`, `previousQuantity`.
143
+
144
+ **Example**
145
+
146
+ ```javascript
147
+ window.addEventListener('lce:actions.product_quantity_increase', (event) => {
148
+ const { data } = event.detail;
149
+ console.log('Quantity increased to', data.quantity);
150
+ });
151
+ ```
152
+
153
+ ### `lce:actions.product_quantity_decrease`
154
+
155
+ Fires when the product quantity is decreased.
156
+
157
+ **Data includes:** `identifier`, `quantity`, `previousQuantity`.
158
+
159
+ **Example**
160
+
161
+ ```javascript
162
+ window.addEventListener('lce:actions.product_quantity_decrease', (event) => {
163
+ const { data } = event.detail;
164
+ console.log('Quantity decreased to', data.quantity);
165
+ });
166
+ ```
167
+
168
+ ## Address Events
169
+
170
+ ### `lce:actions.address_updated`
171
+
172
+ Fires when an address is successfully set.
173
+
174
+ **Data includes:** `googlePlacesId`, `formattedAddress`, `address`, `coordinates`.
175
+
176
+ **Example**
177
+
178
+ ```javascript
179
+ window.addEventListener('lce:actions.address_updated', (event) => {
180
+ const { data } = event.detail;
181
+ console.log('Address set:', data.formattedAddress);
182
+ });
183
+ ```
184
+
185
+ ### `lce:actions.address_cleared`
186
+
187
+ Fires when the current address is cleared.
188
+
189
+ **Data includes:** `true`.
190
+
191
+ **Example**
192
+
193
+ ```javascript
194
+ window.addEventListener('lce:actions.address_cleared', () => {
195
+ console.log('Address cleared');
196
+ });
197
+ ```
198
+
199
+ ### `lce:actions.address_failed`
200
+
201
+ Fires when setting the address fails.
202
+
203
+ **Data includes:** `googlePlacesId`, `formattedAddress`, `address`, `coordinates`, `error`.
204
+
205
+ **Example**
206
+
207
+ ```javascript
208
+ window.addEventListener('lce:actions.address_failed', (event) => {
209
+ const { data } = event.detail;
210
+ console.error('Address error:', data.error);
211
+ });
212
+ ```
213
+
214
+ ## Cart Events
215
+
216
+ ### `lce:actions.cart_loaded`
217
+
218
+ Fires when the cart is fully loaded or synced.
219
+
220
+ **Data includes:** `cartId`, `itemCount`, `subtotal`, `items`, `promoCodeDiscount`.
221
+
222
+ **Example**
223
+
224
+ ```javascript
225
+ window.addEventListener('lce:actions.cart_loaded', (event) => {
226
+ const { data } = event.detail;
227
+ console.log(`Cart ${data.cartId} has ${data.itemCount} items`);
228
+ });
229
+ ```
230
+
231
+ ### `lce:actions.cart_opened`
232
+
233
+ Fires when the cart drawer opens.
234
+
235
+ **Data includes:** `true`.
236
+
237
+ **Example**
238
+
239
+ ```javascript
240
+ window.addEventListener('lce:actions.cart_opened', () => {
241
+ document.body.classList.add('cart-open');
242
+ });
243
+ ```
244
+
245
+ ### `lce:actions.cart_closed`
246
+
247
+ Fires when the cart drawer closes.
248
+
249
+ **Data includes:** `true`.
250
+
251
+ **Example**
252
+
253
+ ```javascript
254
+ window.addEventListener('lce:actions.cart_closed', () => {
255
+ document.body.classList.remove('cart-open');
256
+ });
257
+ ```
258
+
259
+ ### `lce:actions.cart_updated`
260
+
261
+ Fires when cart contents or totals change.
262
+
263
+ **Data includes:** `previous`, `current`.
264
+
265
+ **Example**
266
+
267
+ ```javascript
268
+ window.addEventListener('lce:actions.cart_updated', (event) => {
269
+ const { data } = event.detail;
270
+ const delta = data.current.itemCount - data.previous.itemCount;
271
+ if (delta !== 0) {
272
+ console.log('Item count changed by', delta);
273
+ }
274
+ });
275
+ ```
276
+
277
+ ### `lce:actions.cart_reset`
278
+
279
+ Fires when the cart is cleared.
280
+
281
+ **Data includes:** `true`.
282
+
283
+ **Example**
284
+
285
+ ```javascript
286
+ window.addEventListener('lce:actions.cart_reset', () => {
287
+ console.log('Cart reset');
288
+ });
289
+ ```
290
+
291
+ ### `lce:actions.cart_failed`
292
+
293
+ Fires when a cart operation fails.
294
+
295
+ **Data includes:** `cartId`, `message`.
296
+
297
+ **Example**
298
+
299
+ ```javascript
300
+ window.addEventListener('lce:actions.cart_failed', (event) => {
301
+ const { data } = event.detail;
302
+ console.error('Cart error:', data.message);
303
+ });
304
+ ```
305
+
306
+ ### `lce:actions.cart_item_added`
307
+
308
+ Fires when an item is added to the cart.
309
+
310
+ **Data includes:** `cartId`, `itemId`, `quantity`, `fulfillmentId`, `partNumber`.
311
+
312
+ **Example**
313
+
314
+ ```javascript
315
+ window.addEventListener('lce:actions.cart_item_added', (event) => {
316
+ const { data } = event.detail;
317
+ console.log(`Added item ${data.itemId} (qty ${data.quantity})`);
318
+ });
319
+ ```
320
+
321
+ ### `lce:actions.cart_item_removed`
322
+
323
+ Fires when an item is removed from the cart.
324
+
325
+ **Data includes:** `cartId`, `itemId`.
326
+
327
+ **Example**
328
+
329
+ ```javascript
330
+ window.addEventListener('lce:actions.cart_item_removed', (event) => {
331
+ const { data } = event.detail;
332
+ console.log('Removed item', data.itemId);
333
+ });
334
+ ```
335
+
336
+ ### `lce:actions.cart_item_quantity_increase`
337
+
338
+ Fires when a cart item quantity increases.
339
+
340
+ **Data includes:** `cartId`, `itemId`, `quantity`, `previousQuantity`.
341
+
342
+ **Example**
343
+
344
+ ```javascript
345
+ window.addEventListener('lce:actions.cart_item_quantity_increase', (event) => {
346
+ const { data } = event.detail;
347
+ console.log('Quantity increased to', data.quantity);
348
+ });
349
+ ```
350
+
351
+ ### `lce:actions.cart_item_quantity_decrease`
352
+
353
+ Fires when a cart item quantity decreases.
354
+
355
+ **Data includes:** `cartId`, `itemId`, `quantity`, `previousQuantity`.
356
+
357
+ **Example**
358
+
359
+ ```javascript
360
+ window.addEventListener('lce:actions.cart_item_quantity_decrease', (event) => {
361
+ const { data } = event.detail;
362
+ console.log('Quantity decreased to', data.quantity);
363
+ });
364
+ ```
365
+
366
+ ### `lce:actions.cart_item_engraving_updated`
367
+
368
+ Fires when engraving text is updated for a cart item.
369
+
370
+ **Data includes:** `cartId`, `itemId`, `engravingLines`, `previousEngravingLines`.
371
+
372
+ **Example**
373
+
374
+ ```javascript
375
+ window.addEventListener('lce:actions.cart_item_engraving_updated', (event) => {
376
+ const { data } = event.detail;
377
+ console.log('Updated engraving for', data.itemId);
378
+ });
379
+ ```
380
+
381
+ ### `lce:actions.cart_promo_code_applied`
382
+
383
+ Fires when a promo code is applied to the cart.
384
+
385
+ **Data includes:** `cartId`, `discount`, `newSubtotal`.
386
+
387
+ **Example**
388
+
389
+ ```javascript
390
+ window.addEventListener('lce:actions.cart_promo_code_applied', (event) => {
391
+ const { data } = event.detail;
392
+ console.log('Promo applied, discount:', data.discount);
393
+ });
394
+ ```
395
+
396
+ ### `lce:actions.cart_promo_code_removed`
397
+
398
+ Fires when a promo code is removed from the cart.
399
+
400
+ **Data includes:** `cartId`, `discount`, `newSubtotal`.
401
+
402
+ **Example**
403
+
404
+ ```javascript
405
+ window.addEventListener('lce:actions.cart_promo_code_removed', (event) => {
406
+ const { data } = event.detail;
407
+ console.log('Promo removed');
408
+ });
409
+ ```
410
+
411
+ ### `lce:actions.cart_promo_code_failed`
412
+
413
+ Fires when a promo code fails to apply.
414
+
415
+ **Data includes:** `cartId`, `error`.
416
+
417
+ **Example**
418
+
419
+ ```javascript
420
+ window.addEventListener('lce:actions.cart_promo_code_failed', (event) => {
421
+ const { data } = event.detail;
422
+ console.error('Promo code failed:', data.error);
423
+ });
424
+ ```
425
+
426
+ ### `lce:actions.cart_product_add_success`
427
+
428
+ Fires when adding products via the actions API succeeds.
429
+
430
+ **Data includes:** `cartId`, `itemsAdded`, `identifiers`.
431
+
432
+ **Example**
433
+
434
+ ```javascript
435
+ window.addEventListener('lce:actions.cart_product_add_success', (event) => {
436
+ const { data } = event.detail;
437
+ console.log(`Added ${data.itemsAdded} products`);
438
+ });
439
+ ```
440
+
441
+ ### `lce:actions.cart_product_add_failed`
442
+
443
+ Fires when adding products via the actions API fails.
444
+
445
+ **Data includes:** `cartId`, `identifiers`, `error`.
446
+
447
+ **Example**
448
+
449
+ ```javascript
450
+ window.addEventListener('lce:actions.cart_product_add_failed', (event) => {
451
+ const { data } = event.detail;
452
+ console.error('Product add failed:', data.error);
453
+ });
454
+ ```
455
+
456
+ ## Checkout Events
457
+
458
+ ### `lce:actions.checkout_loaded`
459
+
460
+ Fires when checkout data loads.
461
+
462
+ **Data includes:** `cartId`, `amounts`, `itemCount`, `isGift`, `billingSameAsShipping`.
463
+
464
+ **Example**
465
+
466
+ ```javascript
467
+ window.addEventListener('lce:actions.checkout_loaded', (event) => {
468
+ const { data } = event.detail;
469
+ console.log('Checkout loaded for cart', data.cartId);
470
+ });
471
+ ```
472
+
473
+ ### `lce:actions.checkout_opened`
474
+
475
+ Fires when the checkout drawer opens.
476
+
477
+ **Data includes:** `true`.
478
+
479
+ **Example**
480
+
481
+ ```javascript
482
+ window.addEventListener('lce:actions.checkout_opened', () => {
483
+ console.log('Checkout opened');
484
+ });
485
+ ```
486
+
487
+ ### `lce:actions.checkout_closed`
488
+
489
+ Fires when the checkout drawer closes.
490
+
491
+ **Data includes:** `true`.
492
+
493
+ **Example**
494
+
495
+ ```javascript
496
+ window.addEventListener('lce:actions.checkout_closed', () => {
497
+ console.log('Checkout closed');
498
+ });
499
+ ```
500
+
501
+ ### `lce:actions.checkout_failed`
502
+
503
+ Fires when checkout fails to load or operate.
504
+
505
+ **Data includes:** `message`.
506
+
507
+ **Example**
508
+
509
+ ```javascript
510
+ window.addEventListener('lce:actions.checkout_failed', (event) => {
511
+ const { data } = event.detail;
512
+ console.error('Checkout error:', data.message);
513
+ });
514
+ ```
515
+
516
+ ### `lce:actions.checkout_customer_information_updated`
517
+
518
+ Fires when customer info (email, phone, name) is updated.
519
+
520
+ **Data includes:** `cartId`.
521
+
522
+ **Example**
523
+
524
+ ```javascript
525
+ window.addEventListener('lce:actions.checkout_customer_information_updated', (event) => {
526
+ const { data } = event.detail;
527
+ console.log('Customer info updated for cart', data.cartId);
528
+ });
529
+ ```
530
+
531
+ ### `lce:actions.checkout_billing_information_updated`
532
+
533
+ Fires when billing info is updated.
534
+
535
+ **Data includes:** `cartId`.
536
+
537
+ **Example**
538
+
539
+ ```javascript
540
+ window.addEventListener('lce:actions.checkout_billing_information_updated', (event) => {
541
+ const { data } = event.detail;
542
+ console.log('Billing info updated for cart', data.cartId);
543
+ });
544
+ ```
545
+
546
+ ### `lce:actions.checkout_gift_information_updated`
547
+
548
+ Fires when gift recipient info is updated.
549
+
550
+ **Data includes:** `cartId`.
551
+
552
+ **Example**
553
+
554
+ ```javascript
555
+ window.addEventListener('lce:actions.checkout_gift_information_updated', (event) => {
556
+ const { data } = event.detail;
557
+ console.log('Gift info updated for cart', data.cartId);
558
+ });
559
+ ```
560
+
561
+ ### `lce:actions.checkout_is_gift_toggled`
562
+
563
+ Fires when gift mode is toggled.
564
+
565
+ **Data includes:** `cartId`, `isActive`, `previousIsActive`.
566
+
567
+ **Example**
568
+
569
+ ```javascript
570
+ window.addEventListener('lce:actions.checkout_is_gift_toggled', (event) => {
571
+ const { data } = event.detail;
572
+ console.log('Gift mode:', data.isActive);
573
+ });
574
+ ```
575
+
576
+ ### `lce:actions.checkout_billing_same_as_shipping_toggled`
577
+
578
+ Fires when the billing same-as-shipping option is toggled.
579
+
580
+ **Data includes:** `cartId`, `isActive`, `previousIsActive`.
581
+
582
+ **Example**
583
+
584
+ ```javascript
585
+ window.addEventListener('lce:actions.checkout_billing_same_as_shipping_toggled', (event) => {
586
+ const { data } = event.detail;
587
+ console.log('Billing same as shipping:', data.isActive);
588
+ });
589
+ ```
590
+
591
+ ### `lce:actions.checkout_marketing_preferences_toggled`
592
+
593
+ Fires when a marketing preference is toggled.
594
+
595
+ **Data includes:** `cartId`, `fieldName`, `isActive`, `previousIsActive`.
596
+
597
+ **Example**
598
+
599
+ ```javascript
600
+ window.addEventListener('lce:actions.checkout_marketing_preferences_toggled', (event) => {
601
+ const { data } = event.detail;
602
+ console.log(`Marketing ${data.fieldName}:`, data.isActive);
603
+ });
604
+ ```
605
+
606
+ ### `lce:actions.checkout_item_removed`
607
+
608
+ Fires when an item is removed during checkout.
609
+
610
+ **Data includes:** `cartId`, `cartItemId`.
611
+
612
+ **Example**
613
+
614
+ ```javascript
615
+ window.addEventListener('lce:actions.checkout_item_removed', (event) => {
616
+ const { data } = event.detail;
617
+ console.log('Checkout item removed', data.cartItemId);
618
+ });
619
+ ```
620
+
621
+ ### `lce:actions.checkout_item_quantity_increase`
622
+
623
+ Fires when a checkout item quantity increases.
624
+
625
+ **Data includes:** `cartId`, `cartItemId`, `quantity`, `previousQuantity`.
626
+
627
+ **Example**
628
+
629
+ ```javascript
630
+ window.addEventListener('lce:actions.checkout_item_quantity_increase', (event) => {
631
+ const { data } = event.detail;
632
+ console.log('Checkout quantity increased to', data.quantity);
633
+ });
634
+ ```
635
+
636
+ ### `lce:actions.checkout_item_quantity_decrease`
637
+
638
+ Fires when a checkout item quantity decreases.
639
+
640
+ **Data includes:** `cartId`, `cartItemId`, `quantity`, `previousQuantity`.
641
+
642
+ **Example**
643
+
644
+ ```javascript
645
+ window.addEventListener('lce:actions.checkout_item_quantity_decrease', (event) => {
646
+ const { data } = event.detail;
647
+ console.log('Checkout quantity decreased to', data.quantity);
648
+ });
649
+ ```
650
+
651
+ ### `lce:actions.checkout_item_engraving_updated`
652
+
653
+ Fires when engraving text is updated for a checkout item.
654
+
655
+ **Data includes:** `cartId`, `cartItemId`, `engravingLines`, `previousEngravingLines`.
656
+
657
+ **Example**
658
+
659
+ ```javascript
660
+ window.addEventListener('lce:actions.checkout_item_engraving_updated', (event) => {
661
+ const { data } = event.detail;
662
+ console.log('Checkout engraving updated for', data.cartItemId);
663
+ });
664
+ ```
665
+
666
+ ### `lce:actions.checkout_tip_updated`
667
+
668
+ Fires when delivery tips are updated.
669
+
670
+ **Data includes:** `cartId`, `deliveryTips`, `previousDeliveryTips`.
671
+
672
+ **Example**
673
+
674
+ ```javascript
675
+ window.addEventListener('lce:actions.checkout_tip_updated', (event) => {
676
+ const { data } = event.detail;
677
+ console.log('Tips updated for cart', data.cartId);
678
+ });
679
+ ```
680
+
681
+ ### `lce:actions.checkout_submit_started`
682
+
683
+ Fires when checkout submission starts.
684
+
685
+ **Data includes:** `started`.
686
+
687
+ **Example**
688
+
689
+ ```javascript
690
+ window.addEventListener('lce:actions.checkout_submit_started', (event) => {
691
+ const { data } = event.detail;
692
+ if (data.started) {
693
+ console.log('Checkout submission started');
694
+ }
695
+ });
696
+ ```
697
+
698
+ ### `lce:actions.checkout_submit_completed`
699
+
700
+ Fires when checkout submission completes successfully.
701
+
702
+ **Data includes:** `orderNumber`, `orderTotal`.
703
+
704
+ **Example**
705
+
706
+ ```javascript
707
+ window.addEventListener('lce:actions.checkout_submit_completed', (event) => {
708
+ const { data } = event.detail;
709
+ console.log('Order completed:', data.orderNumber);
710
+ });
711
+ ```
712
+
713
+ ### `lce:actions.checkout_submit_failed`
714
+
715
+ Fires when checkout submission fails.
716
+
717
+ **Data includes:** `message`.
718
+
719
+ **Example**
720
+
721
+ ```javascript
722
+ window.addEventListener('lce:actions.checkout_submit_failed', (event) => {
723
+ const { data } = event.detail;
724
+ console.error('Checkout submit failed:', data.message);
725
+ });
726
+ ```
727
+
728
+ ### `lce:actions.checkout_promo_code_applied`
729
+
730
+ Fires when a promo code is applied during checkout.
731
+
732
+ **Data includes:** `cartId`, `discount`, `newTotal`.
733
+
734
+ **Example**
735
+
736
+ ```javascript
737
+ window.addEventListener('lce:actions.checkout_promo_code_applied', (event) => {
738
+ const { data } = event.detail;
739
+ console.log('Checkout promo applied:', data.discount);
740
+ });
741
+ ```
742
+
743
+ ### `lce:actions.checkout_promo_code_removed`
744
+
745
+ Fires when a promo code is removed during checkout.
746
+
747
+ **Data includes:** `cartId`, `discount`, `newTotal`.
748
+
749
+ **Example**
750
+
751
+ ```javascript
752
+ window.addEventListener('lce:actions.checkout_promo_code_removed', (event) => {
753
+ const { data } = event.detail;
754
+ console.log('Checkout promo removed');
755
+ });
756
+ ```
757
+
758
+ ### `lce:actions.checkout_promo_code_failed`
759
+
760
+ Fires when a promo code fails during checkout.
761
+
762
+ **Data includes:** `cartId`, `error`.
763
+
764
+ **Example**
765
+
766
+ ```javascript
767
+ window.addEventListener('lce:actions.checkout_promo_code_failed', (event) => {
768
+ const { data } = event.detail;
769
+ console.error('Checkout promo failed:', data.error);
770
+ });
771
+ ```
772
+
773
+ ### `lce:actions.checkout_gift_card_applied`
774
+
775
+ Fires when a gift card is applied during checkout.
776
+
777
+ **Data includes:** `cartId`, `newTotal`.
778
+
779
+ **Example**
780
+
781
+ ```javascript
782
+ window.addEventListener('lce:actions.checkout_gift_card_applied', (event) => {
783
+ const { data } = event.detail;
784
+ console.log('Gift card applied, new total:', data.newTotal);
785
+ });
786
+ ```
787
+
788
+ ### `lce:actions.checkout_gift_card_removed`
789
+
790
+ Fires when a gift card is removed during checkout.
791
+
792
+ **Data includes:** `cartId`, `newTotal`.
793
+
794
+ **Example**
795
+
796
+ ```javascript
797
+ window.addEventListener('lce:actions.checkout_gift_card_removed', (event) => {
798
+ const { data } = event.detail;
799
+ console.log('Gift card removed');
800
+ });
801
+ ```
802
+
803
+ ### `lce:actions.checkout_gift_card_failed`
804
+
805
+ Fires when a gift card fails during checkout.
806
+
807
+ **Data includes:** `cartId`, `error`.
808
+
809
+ **Example**
810
+
811
+ ```javascript
812
+ window.addEventListener('lce:actions.checkout_gift_card_failed', (event) => {
813
+ const { data } = event.detail;
814
+ console.error('Gift card failed:', data.error);
815
+ });
816
+ ```
817
+
818
+ ### `lce:actions.checkout_product_add_success`
819
+
820
+ Fires when products are added to checkout via the actions API.
821
+
822
+ **Data includes:** `cartId`, `itemsAdded`, `identifiers`, `isPresale`.
823
+
824
+ **Example**
825
+
826
+ ```javascript
827
+ window.addEventListener('lce:actions.checkout_product_add_success', (event) => {
828
+ const { data } = event.detail;
829
+ console.log(`Checkout added ${data.itemsAdded} products`);
830
+ });
831
+ ```
832
+
833
+ ### `lce:actions.checkout_product_add_failed`
834
+
835
+ Fires when adding products to checkout via the actions API fails.
836
+
837
+ **Data includes:** `cartId`, `identifiers`, `error`, `isPresale`.
838
+
839
+ **Example**
840
+
841
+ ```javascript
842
+ window.addEventListener('lce:actions.checkout_product_add_failed', (event) => {
843
+ const { data } = event.detail;
844
+ console.error('Checkout product add failed:', data.error);
845
+ });
846
+ ```
847
+
848
+ ## Form Events
849
+
850
+ ### `lce:forms.customer`
851
+
852
+ Fires when a customer form field changes in checkout.
853
+
854
+ **Data includes:** `fieldName`, `fieldValue`.
855
+
856
+ **Example**
857
+
858
+ ```javascript
859
+ window.addEventListener('lce:forms.customer', (event) => {
860
+ const { data } = event.detail;
861
+ console.log('Customer field changed:', data.fieldName);
862
+ });
863
+ ```
864
+
865
+ ### `lce:forms.billing`
866
+
867
+ Fires when a billing form field changes in checkout.
868
+
869
+ **Data includes:** `fieldName`, `fieldValue`.
870
+
871
+ **Example**
872
+
873
+ ```javascript
874
+ window.addEventListener('lce:forms.billing', (event) => {
875
+ const { data } = event.detail;
876
+ console.log('Billing field changed:', data.fieldName);
877
+ });
878
+ ```
879
+
880
+ ### `lce:forms.gift`
881
+
882
+ Fires when a gift form field changes in checkout.
883
+
884
+ **Data includes:** `fieldName`, `fieldValue`.
885
+
886
+ **Example**
887
+
888
+ ```javascript
889
+ window.addEventListener('lce:forms.gift', (event) => {
890
+ const { data } = event.detail;
891
+ console.log('Gift field changed:', data.fieldName);
892
+ });
893
+ ```
894
+
895
+ ## Use Cases
896
+
897
+ ### Analytics Integration
898
+
899
+ ```javascript
900
+ // Track product views
901
+ window.addEventListener('lce:actions.product_loaded', (event) => {
902
+ const { data } = event.detail;
903
+ gtag('event', 'view_item', {
904
+ items: [{
905
+ item_id: data.identifier,
906
+ item_name: data.name,
907
+ price: data.price / 100
908
+ }]
909
+ });
910
+ });
911
+
912
+ // Track purchases
913
+ window.addEventListener('lce:actions.checkout_submit_completed', (event) => {
914
+ const { data } = event.detail;
915
+ gtag('event', 'purchase', {
916
+ transaction_id: data.orderNumber,
917
+ value: data.orderTotal / 100,
918
+ currency: 'USD'
919
+ });
920
+ });
921
+ ```
922
+
923
+ ## See Also
924
+
925
+ - [Component Guides](../guides/)
926
+ - [Actions API](../api/actions/)