@liquidcommerce/elements-sdk 2.7.1 → 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.
@@ -3,6 +3,7 @@
3
3
  Actions let you control Elements programmatically after the SDK initializes. All actions live under `window.elements.actions.*`.
4
4
 
5
5
  ## Quick start
6
+
6
7
  ```js
7
8
  window.addEventListener('lce:actions.client_ready', () => {
8
9
  window.elements.actions.cart.openCart();
@@ -10,98 +11,679 @@ window.addEventListener('lce:actions.client_ready', () => {
10
11
  ```
11
12
 
12
13
  ## Product actions
13
- - `actions.product.getDetails(identifier)`
14
- Returns the current loaded product data (price, size, fulfillment, retailer, quantity, images, etc.). The product must already be injected and loaded.
14
+
15
+ ### `actions.product.getDetails(identifier)`
16
+
17
+ Returns the current loaded product data (price, size, fulfillment, retailer, quantity, images, and more). The product must already be injected and loaded.
18
+
19
+ **Signature**
20
+
21
+ ```ts
22
+ getDetails(identifier: string): IBaseProductEventData
23
+ ```
24
+
25
+ **Return shape (TypeScript)**
26
+
27
+ ```ts
28
+ export type FulfillmentType = 'onDemand' | 'shipping';
29
+
30
+ export interface IBaseProductEventData {
31
+ identifier: string;
32
+ selectedSizeId: string | null;
33
+ selectedFulfillmentType: FulfillmentType;
34
+ selectedFulfillmentId: string | null;
35
+ productHasAvailability: boolean;
36
+ fulfillmentHasAvailability: boolean;
37
+ sizes: Record<string, IProductSizeEventData>;
38
+
39
+ id: string;
40
+ name: string;
41
+ description: string;
42
+ htmlDescription: string;
43
+ images: string[];
44
+ brand: string;
45
+ region: string;
46
+ country: string;
47
+ material: string;
48
+ abv: string;
49
+ proof: string;
50
+ age: string;
51
+ color: string;
52
+ flavor: string;
53
+ variety: string;
54
+ appellation: string;
55
+ vintage: string;
56
+ tastingNotes: string;
57
+ catPath: string;
58
+ category: string;
59
+ classification: string;
60
+ type: string;
61
+ subType: string;
62
+ salsifyGrouping: string;
63
+ noAvailabilityPrice: number;
64
+ }
65
+
66
+ export interface IProductSizeEventData {
67
+ id: string;
68
+ upc: string;
69
+ size: string;
70
+ pack: boolean;
71
+ packDesc: string;
72
+ container: string;
73
+ containerType: string;
74
+ image: string;
75
+ uom: string;
76
+ volume: string;
77
+ maxQuantityPerOrder: number;
78
+ attributes: IProductSizeAttributes;
79
+ onDemandFulfillments: Record<string, IProductFulfillmentEventData>;
80
+ shippingFulfillments: Record<string, IProductFulfillmentEventData>;
81
+ }
82
+
83
+ export interface IProductSizeAttributes {
84
+ presale: IProductPresale;
85
+ engraving: IProductSizeEngraving;
86
+ }
87
+
88
+ export interface IProductSizeEngraving {
89
+ maxLines: number;
90
+ maxCharsPerLine: number;
91
+ fee: number;
92
+ location: string;
93
+ }
94
+
95
+ export interface IProductPresale {
96
+ canPurchaseOn: string | null;
97
+ estimatedShipBy: string | null;
98
+ isActive: boolean;
99
+ language: string;
100
+ }
101
+
102
+ export interface IProductFulfillmentEventData {
103
+ id: string;
104
+ type: FulfillmentType;
105
+ doesAllowGiftCards: boolean;
106
+ doesAllowPromos: boolean;
107
+ expectation: string;
108
+ engravingExpectation: string;
109
+ fee: number;
110
+ timezone: string;
111
+ hourStatus: IProductFulfillmentHourStatus;
112
+ retailerName: string;
113
+ retailerAddress: IRetailerAddress;
114
+ retailerAddressFormatted: string;
115
+ variant: IProductVariant;
116
+ }
117
+
118
+ export interface IProductFulfillmentHourStatus {
119
+ isOpen: boolean;
120
+ openTime: string;
121
+ isClosed: boolean;
122
+ closeTime: string;
123
+ }
124
+
125
+ export interface IProductVariant {
126
+ retailerId: string;
127
+ shippingFulfillmentId: string;
128
+ onDemandFulfillmentId: string;
129
+ isEngravable: boolean;
130
+ partNumber: string;
131
+ price: number;
132
+ stock: number;
133
+ }
134
+
135
+ export type IRetailerAddress = IAddressAddress & IAddressCoordinates;
136
+
137
+ export interface IAddressAddress {
138
+ one: string;
139
+ two: string;
140
+ city: string;
141
+ state: string;
142
+ zip: string;
143
+ country: string;
144
+ }
145
+
146
+ export interface IAddressCoordinates {
147
+ latitude: number;
148
+ longitude: number;
149
+ }
150
+ ```
151
+
152
+ **Example**
15
153
 
16
154
  ```js
17
155
  const product = window.elements.actions.product.getDetails('00619947000020');
18
- console.log(product.name, product.price);
156
+ console.log(product.name, product.price / 100);
19
157
  ```
20
158
 
21
159
  ## Cart actions
22
- - `actions.cart.openCart()`
23
- Opens the cart drawer.
24
- - `actions.cart.closeCart()`
25
- Closes the cart drawer.
26
- - `actions.cart.toggleCart()`
27
- Toggles the cart drawer open/closed.
28
- - `actions.cart.addProduct(params[], openCart?)`
29
- Adds one or more products to the cart. If no address is set, the SDK prompts for one and retries automatically.
30
- - `actions.cart.applyPromoCode(promoCode)`
31
- Applies a promo code (replaces any existing code).
32
- - `actions.cart.removePromoCode()`
33
- Removes the active promo code.
34
- - `actions.cart.resetCart()`
35
- Clears all cart items (no undo).
36
- - `actions.cart.getDetails()`
37
- Returns current cart data (items, totals, promo, retailers, etc.).
160
+
161
+ ### `actions.cart.openCart()`
162
+
163
+ Opens the cart drawer.
164
+
165
+ **Signature**
166
+
167
+ ```ts
168
+ openCart(): void
169
+ ```
170
+
171
+ **Example**
172
+
173
+ ```js
174
+ window.elements.actions.cart.openCart();
175
+ ```
176
+
177
+ ### `actions.cart.closeCart()`
178
+
179
+ Closes the cart drawer.
180
+
181
+ **Signature**
182
+
183
+ ```ts
184
+ closeCart(): void
185
+ ```
186
+
187
+ **Example**
188
+
189
+ ```js
190
+ window.elements.actions.cart.closeCart();
191
+ ```
192
+
193
+ ### `actions.cart.toggleCart()`
194
+
195
+ Toggles the cart drawer open/closed.
196
+
197
+ **Signature**
198
+
199
+ ```ts
200
+ toggleCart(): void
201
+ ```
202
+
203
+ **Example**
204
+
205
+ ```js
206
+ document.getElementById('cart-btn').addEventListener('click', () => {
207
+ window.elements.actions.cart.toggleCart();
208
+ });
209
+ ```
210
+
211
+ ### `actions.cart.addProduct(params[], openCart?)`
212
+
213
+ Adds one or more products to the cart. If no address is set, the SDK prompts for one and retries automatically.
214
+
215
+ **Signature**
216
+
217
+ ```ts
218
+ addProduct(params: IAddProductParams[], openCart?: boolean): Promise<void>
219
+ ```
220
+
221
+ **Parameters (TypeScript)**
222
+
223
+ ```ts
224
+ export type FulfillmentType = 'onDemand' | 'shipping';
225
+
226
+ export interface IAddProductParams {
227
+ identifier: string;
228
+ fulfillmentType: FulfillmentType;
229
+ quantity: number;
230
+ }
231
+ ```
232
+
233
+ **Example**
38
234
 
39
235
  ```js
40
236
  await window.elements.actions.cart.addProduct([
41
- { identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }
237
+ { identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 },
238
+ { identifier: '08504405135', fulfillmentType: 'onDemand', quantity: 2 }
42
239
  ], true);
240
+ ```
241
+
242
+ ### `actions.cart.applyPromoCode(promoCode)`
243
+
244
+ Applies a promo code to the cart (replaces any existing code).
245
+
246
+ **Signature**
247
+
248
+ ```ts
249
+ applyPromoCode(promoCode: string): Promise<void>
250
+ ```
251
+
252
+ **Example**
253
+
254
+ ```js
255
+ try {
256
+ await window.elements.actions.cart.applyPromoCode('SUMMER20');
257
+ } catch (error) {
258
+ console.error('Promo code invalid:', error);
259
+ }
260
+ ```
261
+
262
+ ### `actions.cart.removePromoCode()`
263
+
264
+ Removes the active promo code.
265
+
266
+ **Signature**
267
+
268
+ ```ts
269
+ removePromoCode(): Promise<void>
270
+ ```
271
+
272
+ **Example**
43
273
 
44
- await window.elements.actions.cart.applyPromoCode('SUMMER20');
274
+ ```js
45
275
  await window.elements.actions.cart.removePromoCode();
276
+ ```
277
+
278
+ ### `actions.cart.resetCart()`
279
+
280
+ Clears all cart items (no undo).
281
+
282
+ **Signature**
283
+
284
+ ```ts
285
+ resetCart(): Promise<void>
286
+ ```
287
+
288
+ **Example**
289
+
290
+ ```js
46
291
  await window.elements.actions.cart.resetCart();
292
+ ```
293
+
294
+ ### `actions.cart.getDetails()`
295
+
296
+ Returns current cart data (items, totals, promo, retailers, location, etc.).
297
+
298
+ **Signature**
299
+
300
+ ```ts
301
+ getDetails(): IBaseCartEventData
302
+ ```
303
+
304
+ **Return shape (TypeScript)**
305
+
306
+ ```ts
307
+ export type FulfillmentType = 'onDemand' | 'shipping';
308
+
309
+ export interface IBaseCartEventData {
310
+ cartId: string;
311
+ promoCodeDiscount: number | null;
312
+ subtotal: number;
313
+ itemCount: number;
314
+ items: Record<string, ICartItem>;
315
+ retailers: Record<string, ICartRetailer>;
316
+ location: {
317
+ placesId: string;
318
+ formattedAddress: string;
319
+ address: IAddressAddress;
320
+ coordinates: IAddressCoordinates;
321
+ } | null;
322
+ }
47
323
 
324
+ export interface ICartItem {
325
+ id: string;
326
+ variantId: string;
327
+ liquidId: string;
328
+ retailerId: string;
329
+ partNumber: string;
330
+ fulfillmentId: string;
331
+ upc: string;
332
+ sku: string;
333
+ salsifyGrouping: string;
334
+ catPath: string;
335
+ volume: string;
336
+ uom: string;
337
+ pack: boolean;
338
+ packDesc: string;
339
+ container: string;
340
+ containerType: string;
341
+ name: string;
342
+ brand: string;
343
+ size: string;
344
+ price: number;
345
+ quantity: number;
346
+ maxQuantity: number;
347
+ unitPrice: number;
348
+ mainImage: string;
349
+ attributes: ICartItemAttributes;
350
+ }
351
+
352
+ export interface ICartItemAttributes {
353
+ engraving: ICartItemEngraving;
354
+ presale: IProductPresale;
355
+ }
356
+
357
+ export interface ICartItemEngraving {
358
+ isEngravable: boolean;
359
+ hasEngraving: boolean;
360
+ fee: number;
361
+ maxCharsPerLine: number;
362
+ maxLines: number;
363
+ location: string;
364
+ lines: string[];
365
+ }
366
+
367
+ export interface IProductPresale {
368
+ canPurchaseOn: string | null;
369
+ estimatedShipBy: string | null;
370
+ isActive: boolean;
371
+ language: string;
372
+ }
373
+
374
+ export interface ICartRetailer {
375
+ id: string;
376
+ name: string;
377
+ subtotal: number;
378
+ itemsQuantity: number;
379
+ fulfillments: Record<string, ICartFulfillment>;
380
+ }
381
+
382
+ export interface ICartFulfillment {
383
+ id: string;
384
+ canEngrave: boolean;
385
+ type: FulfillmentType;
386
+ expectation: string;
387
+ engravingExpectation: string;
388
+ itemIds: string[];
389
+ subtotal: number;
390
+ hasUnmetMinimumPurchaseAmount: boolean;
391
+ minimumPurchaseAmount: number;
392
+ }
393
+
394
+ export interface IAddressAddress {
395
+ one: string;
396
+ two: string;
397
+ city: string;
398
+ state: string;
399
+ zip: string;
400
+ country: string;
401
+ }
402
+
403
+ export interface IAddressCoordinates {
404
+ latitude: number;
405
+ longitude: number;
406
+ }
407
+ ```
408
+
409
+ **Example**
410
+
411
+ ```js
48
412
  const cart = window.elements.actions.cart.getDetails();
413
+ console.log(cart.cartId, cart.itemCount, cart.subtotal / 100);
49
414
  ```
50
415
 
51
416
  ## Checkout actions
52
- - `actions.checkout.openCheckout()`
53
- Opens the checkout drawer.
54
- - `actions.checkout.closeCheckout()`
55
- Closes the checkout drawer.
56
- - `actions.checkout.toggleCheckout()`
57
- Toggles the checkout drawer open/closed.
58
- - `actions.checkout.exitCheckout()`
59
- Navigates away from checkout (requires `exitUrl` config).
60
- - `actions.checkout.addProduct(params[], openCheckout?)`
61
- Adds products directly to checkout (bypasses cart).
62
- - `actions.checkout.applyPromoCode(promoCode)`
63
- Applies a promo code in checkout.
64
- - `actions.checkout.removePromoCode()`
65
- Removes the active promo code.
66
- - `actions.checkout.applyGiftCard(code)`
67
- Applies a gift card.
68
- - `actions.checkout.removeGiftCard(code)`
69
- Removes a gift card.
70
- - `actions.checkout.toggleIsGift(active?)`
71
- Enables/disables gift mode (or toggles when omitted).
72
- - `actions.checkout.toggleBillingSameAsShipping(active?)`
73
- Sets billing address to match shipping.
74
- - `actions.checkout.toggleMarketingPreferences(field, active)`
75
- Sets marketing opt-in (`canEmail` or `canSms`).
76
- - `actions.checkout.updateCustomerInfo(fields)`
77
- Prefills customer info (name, email, phone, birthdate, etc.).
78
- - `actions.checkout.updateBillingInfo(fields)`
79
- Prefills billing address fields.
80
- - `actions.checkout.updateGiftInfo(fields)`
81
- Prefills gift recipient information.
417
+
418
+ ### `actions.checkout.openCheckout()`
419
+
420
+ Opens the checkout drawer or navigates to checkout.
421
+
422
+ **Signature**
423
+
424
+ ```ts
425
+ openCheckout(): void
426
+ ```
427
+
428
+ **Example**
82
429
 
83
430
  ```js
84
431
  window.elements.actions.checkout.openCheckout();
432
+ ```
433
+
434
+ ### `actions.checkout.closeCheckout()`
435
+
436
+ Closes the checkout drawer.
437
+
438
+ **Signature**
439
+
440
+ ```ts
441
+ closeCheckout(): void
442
+ ```
443
+
444
+ **Example**
445
+
446
+ ```js
85
447
  window.elements.actions.checkout.closeCheckout();
448
+ ```
449
+
450
+ ### `actions.checkout.toggleCheckout()`
451
+
452
+ Toggles the checkout drawer open/closed.
453
+
454
+ **Signature**
455
+
456
+ ```ts
457
+ toggleCheckout(): void
458
+ ```
459
+
460
+ **Example**
461
+
462
+ ```js
86
463
  window.elements.actions.checkout.toggleCheckout();
464
+ ```
465
+
466
+ ### `actions.checkout.exitCheckout()`
467
+
468
+ Navigates away from checkout (requires `exitUrl` configuration).
87
469
 
470
+ **Signature**
471
+
472
+ ```ts
473
+ exitCheckout(): void
474
+ ```
475
+
476
+ **Example**
477
+
478
+ ```js
479
+ window.elements.actions.checkout.exitCheckout();
480
+ ```
481
+
482
+ ### `actions.checkout.addProduct(params[], openCheckout?)`
483
+
484
+ Adds products directly to checkout (bypasses cart).
485
+
486
+ **Signature**
487
+
488
+ ```ts
489
+ addProduct(params: IAddProductParams[], openCheckout?: boolean): Promise<void>
490
+ ```
491
+
492
+ **Parameters (TypeScript)**
493
+
494
+ ```ts
495
+ export type FulfillmentType = 'onDemand' | 'shipping';
496
+
497
+ export interface IAddProductParams {
498
+ identifier: string;
499
+ fulfillmentType: FulfillmentType;
500
+ quantity: number;
501
+ }
502
+ ```
503
+
504
+ **Example**
505
+
506
+ ```js
88
507
  await window.elements.actions.checkout.addProduct([
89
508
  { identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }
90
509
  ], true);
510
+ ```
91
511
 
512
+ ### `actions.checkout.applyPromoCode(promoCode)`
513
+
514
+ Applies a promo code in checkout.
515
+
516
+ **Signature**
517
+
518
+ ```ts
519
+ applyPromoCode(promoCode: string): Promise<void>
520
+ ```
521
+
522
+ **Example**
523
+
524
+ ```js
92
525
  await window.elements.actions.checkout.applyPromoCode('WELCOME10');
93
- await window.elements.actions.checkout.applyGiftCard('GIFT-1234-5678');
526
+ ```
527
+
528
+ ### `actions.checkout.removePromoCode()`
529
+
530
+ Removes the active promo code in checkout.
531
+
532
+ **Signature**
533
+
534
+ ```ts
535
+ removePromoCode(): Promise<void>
536
+ ```
537
+
538
+ **Example**
539
+
540
+ ```js
541
+ await window.elements.actions.checkout.removePromoCode();
542
+ ```
543
+
544
+ ### `actions.checkout.applyGiftCard(code)`
545
+
546
+ Applies a gift card.
547
+
548
+ **Signature**
549
+
550
+ ```ts
551
+ applyGiftCard(code: string): Promise<void>
552
+ ```
553
+
554
+ **Example**
555
+
556
+ ```js
557
+ await window.elements.actions.checkout.applyGiftCard('GIFT-1234-5678-9012');
558
+ ```
559
+
560
+ ### `actions.checkout.removeGiftCard(code)`
561
+
562
+ Removes a gift card.
563
+
564
+ **Signature**
565
+
566
+ ```ts
567
+ removeGiftCard(code: string): Promise<void>
568
+ ```
569
+
570
+ **Example**
571
+
572
+ ```js
573
+ await window.elements.actions.checkout.removeGiftCard('GIFT-1234-5678-9012');
574
+ ```
575
+
576
+ ### `actions.checkout.toggleIsGift(active?)`
577
+
578
+ Enables/disables gift mode (toggles when omitted).
579
+
580
+ **Signature**
94
581
 
582
+ ```ts
583
+ toggleIsGift(active?: boolean): Promise<void>
584
+ ```
585
+
586
+ **Example**
587
+
588
+ ```js
95
589
  await window.elements.actions.checkout.toggleIsGift(true);
590
+ ```
591
+
592
+ ### `actions.checkout.toggleBillingSameAsShipping(active?)`
593
+
594
+ Sets whether billing address matches shipping.
595
+
596
+ **Signature**
597
+
598
+ ```ts
599
+ toggleBillingSameAsShipping(active?: boolean): Promise<void>
600
+ ```
601
+
602
+ **Example**
603
+
604
+ ```js
96
605
  await window.elements.actions.checkout.toggleBillingSameAsShipping(false);
606
+ ```
607
+
608
+ ### `actions.checkout.toggleMarketingPreferences(field, active)`
609
+
610
+ Sets marketing opt-in (`canEmail` or `canSms`).
611
+
612
+ **Signature**
613
+
614
+ ```ts
615
+ toggleMarketingPreferences(field: 'canEmail' | 'canSms', active: boolean): Promise<void>
616
+ ```
617
+
618
+ **Example**
619
+
620
+ ```js
97
621
  await window.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
622
+ ```
623
+
624
+ ### `actions.checkout.updateCustomerInfo(fields)`
625
+
626
+ Prefills customer info (name, email, phone, birthdate, etc.).
627
+
628
+ **Signature**
629
+
630
+ ```ts
631
+ updateCustomerInfo(params: Record<CustomerFieldName, string>): void
632
+ ```
633
+
634
+ **Parameters (TypeScript)**
98
635
 
636
+ ```ts
637
+ export type CustomerFieldName =
638
+ | 'firstName'
639
+ | 'lastName'
640
+ | 'email'
641
+ | 'phone'
642
+ | 'birthDate'
643
+ | 'addressTwo'
644
+ | 'company';
645
+ ```
646
+
647
+ **Example**
648
+
649
+ ```js
99
650
  window.elements.actions.checkout.updateCustomerInfo({
100
651
  firstName: 'John',
101
652
  lastName: 'Doe',
102
- email: 'john@example.com'
653
+ email: 'john@example.com',
654
+ phone: '+15551234567'
103
655
  });
656
+ ```
657
+
658
+ ### `actions.checkout.updateBillingInfo(fields)`
659
+
660
+ Prefills billing address fields.
661
+
662
+ **Signature**
663
+
664
+ ```ts
665
+ updateBillingInfo(params: Record<BillingFieldName, string>): void
666
+ ```
667
+
668
+ **Parameters (TypeScript)**
669
+
670
+ ```ts
671
+ export type BillingFieldName =
672
+ | 'firstName'
673
+ | 'lastName'
674
+ | 'email'
675
+ | 'phone'
676
+ | 'company'
677
+ | 'addressOne'
678
+ | 'addressTwo'
679
+ | 'city'
680
+ | 'state'
681
+ | 'zipCode';
682
+ ```
683
+
684
+ **Example**
104
685
 
686
+ ```js
105
687
  window.elements.actions.checkout.updateBillingInfo({
106
688
  firstName: 'John',
107
689
  lastName: 'Doe',
@@ -110,7 +692,33 @@ window.elements.actions.checkout.updateBillingInfo({
110
692
  state: 'IL',
111
693
  zipCode: '60601'
112
694
  });
695
+ ```
696
+
697
+ ### `actions.checkout.updateGiftInfo(fields)`
698
+
699
+ Prefills gift recipient information.
700
+
701
+ **Signature**
113
702
 
703
+ ```ts
704
+ updateGiftInfo(params: Record<GiftFieldName, string>): void
705
+ ```
706
+
707
+ **Parameters (TypeScript)**
708
+
709
+ ```ts
710
+ export type GiftFieldName =
711
+ | 'firstName'
712
+ | 'lastName'
713
+ | 'email'
714
+ | 'phone'
715
+ | 'addressTwo'
716
+ | 'message';
717
+ ```
718
+
719
+ **Example**
720
+
721
+ ```js
114
722
  window.elements.actions.checkout.updateGiftInfo({
115
723
  firstName: 'Jane',
116
724
  lastName: 'Smith',
@@ -118,39 +726,235 @@ window.elements.actions.checkout.updateGiftInfo({
118
726
  });
119
727
  ```
120
728
 
729
+ ### `actions.checkout.getDetails()`
730
+
731
+ Returns current checkout data (amounts, items, preferences, addresses, gift info, etc.).
732
+
733
+ **Signature**
734
+
735
+ ```ts
736
+ getDetails(): ICheckoutDetailsEventData
737
+ ```
738
+
739
+ **Return shape (TypeScript)**
740
+
741
+ ```ts
742
+ export interface ICheckoutDetailsEventData {
743
+ token: string;
744
+ cartId: string;
745
+ isGift: boolean;
746
+ billingSameAsShipping: boolean;
747
+ marketingPreferences: ICheckoutMarketingPreferences;
748
+ hasPromoCode: boolean;
749
+ hasGiftCards: boolean;
750
+ amounts: ICheckoutAmounts;
751
+ itemCount: number;
752
+ items: Record<string, ICheckoutItem>;
753
+ }
754
+
755
+ export interface ICheckoutMarketingPreferences {
756
+ canEmail: boolean;
757
+ canSms: boolean;
758
+ }
759
+
760
+ export interface ICheckoutAmounts {
761
+ subtotal: number;
762
+ engraving: number;
763
+ service: number;
764
+ shipping: number;
765
+ delivery: number;
766
+ platform: number;
767
+ discounts: number;
768
+ giftCards: number;
769
+ tax: number;
770
+ tip: number;
771
+ total: number;
772
+ }
773
+
774
+ export interface ICheckoutItem {
775
+ variantId: string;
776
+ cartItemId: string;
777
+ liquidId: string;
778
+ retailerId: string;
779
+ fulfillmentId: string;
780
+ salsifyPid?: string;
781
+ salsifyGrouping?: string;
782
+ name: string;
783
+ catPath: string;
784
+ volume: string;
785
+ uom: string;
786
+ proof: string;
787
+ abv: string;
788
+ containerType: string;
789
+ container: string;
790
+ size: string;
791
+ pack: boolean;
792
+ packDesc: string;
793
+ mainImage: string;
794
+ brand: string;
795
+ partNumber: string;
796
+ upc: string;
797
+ sku: string;
798
+ price: number;
799
+ unitPrice: number;
800
+ quantity: number;
801
+ tax: number;
802
+ unitTax: number;
803
+ bottleDeposits: number;
804
+ attributes: ICheckoutItemAttributes;
805
+ }
806
+
807
+ export interface ICheckoutItemAttributes {
808
+ engraving: ICheckoutItemEngraving;
809
+ presale: IProductPresale;
810
+ }
811
+
812
+ export interface ICheckoutItemEngraving {
813
+ isEngravable: boolean;
814
+ hasEngraving: boolean;
815
+ fee: number;
816
+ maxCharsPerLine: number;
817
+ maxLines: number;
818
+ location: string;
819
+ lines: string[];
820
+ }
821
+
822
+ export interface IProductPresale {
823
+ canPurchaseOn: string | null;
824
+ estimatedShipBy: string | null;
825
+ isActive: boolean;
826
+ language: string;
827
+ }
828
+ ```
829
+
830
+ **Example**
831
+
832
+ ```js
833
+ const checkout = window.elements.actions.checkout.getDetails();
834
+ console.log(checkout.cartId, checkout.amounts.total / 100);
835
+ ```
836
+
121
837
  ## Address actions
122
- - `actions.address.setAddressByPlacesId(placesId)`
123
- Sets address using a Google Places ID (recommended).
124
- - `actions.address.setAddressManually(address, coordinates)`
125
- Sets address with your own address + lat/long data.
126
- - `actions.address.getDetails()`
127
- Returns the current address (or null if not set).
128
- - `actions.address.clear()`
129
- Removes the stored address and resets availability.
838
+
839
+ ### `actions.address.setAddressByPlacesId(placesId)`
840
+
841
+ Sets address using a Google Places ID (recommended).
842
+
843
+ **Signature**
844
+
845
+ ```ts
846
+ setAddressByPlacesId(placesId: string): Promise<void>
847
+ ```
848
+
849
+ **Example**
130
850
 
131
851
  ```js
132
852
  await window.elements.actions.address.setAddressByPlacesId('ChIJOwg_06VPwokRYv534QaPC8g');
853
+ ```
854
+
855
+ ### `actions.address.setAddressManually(address, coordinates)`
856
+
857
+ Sets address with your own address + lat/long data.
858
+
859
+ **Signature**
860
+
861
+ ```ts
862
+ setAddressManually(address: IAddressAddress, coordinates: IAddressCoordinates): Promise<void>
863
+ ```
864
+
865
+ **Parameters (TypeScript)**
133
866
 
867
+ ```ts
868
+ export interface IAddressAddress {
869
+ one: string;
870
+ two: string;
871
+ city: string;
872
+ state: string;
873
+ zip: string;
874
+ country: string;
875
+ }
876
+
877
+ export interface IAddressCoordinates {
878
+ latitude: number;
879
+ longitude: number;
880
+ }
881
+ ```
882
+
883
+ **Example**
884
+
885
+ ```js
134
886
  await window.elements.actions.address.setAddressManually(
135
887
  { one: '123 Main Street', city: 'New York', state: 'NY', zip: '10001' },
136
888
  { latitude: 40.7128, longitude: -74.0060 }
137
889
  );
890
+ ```
891
+
892
+ ### `actions.address.getDetails()`
893
+
894
+ Returns the current address (or `null` if not set).
895
+
896
+ **Signature**
138
897
 
898
+ ```ts
899
+ getDetails(): IAddressData | null
900
+ ```
901
+
902
+ **Return shape (TypeScript)**
903
+
904
+ ```ts
905
+ export interface IAddressData {
906
+ id: string;
907
+ formattedAddress: string;
908
+ address: IAddressAddress;
909
+ coordinates: IAddressCoordinates;
910
+ }
911
+
912
+ export interface IAddressAddress {
913
+ one: string;
914
+ two: string;
915
+ city: string;
916
+ state: string;
917
+ zip: string;
918
+ country: string;
919
+ }
920
+
921
+ export interface IAddressCoordinates {
922
+ latitude: number;
923
+ longitude: number;
924
+ }
925
+ ```
926
+
927
+ **Example**
928
+
929
+ ```js
139
930
  const address = window.elements.actions.address.getDetails();
931
+ console.log(address?.formattedAddress);
932
+ ```
933
+
934
+ ### `actions.address.clear()`
935
+
936
+ Removes the stored address and resets availability.
937
+
938
+ **Signature**
939
+
940
+ ```ts
941
+ clear(): Promise<void>
942
+ ```
943
+
944
+ **Example**
945
+
946
+ ```js
140
947
  await window.elements.actions.address.clear();
141
948
  ```
142
949
 
143
950
  ## UI helpers (non-actions)
951
+
144
952
  These helpers live under `window.elements.ui.*` and are commonly used with actions.
145
953
 
146
- - `ui.cartButton(containerId, showItemsCount?)`
147
- Renders a cart button inside the given container.
148
- - `ui.floatingCartButton(showItemsCount?)`
149
- Renders a floating cart button (bottom-right).
150
- - `ui.cartSubtotal(elementId)`
151
- Keeps an element updated with cart subtotal.
152
- - `ui.cartItemsCount(elementId, { hideZero })`
153
- Keeps an element updated with cart item count.
954
+ - `ui.cartButton(containerId, showItemsCount?)` - Renders a cart button inside the given container.
955
+ - `ui.floatingCartButton(showItemsCount?)` - Renders a floating cart button (bottom-right).
956
+ - `ui.cartSubtotal(elementId)` - Keeps an element updated with cart subtotal.
957
+ - `ui.cartItemsCount(elementId, { hideZero })` - Keeps an element updated with cart item count.
154
958
 
155
959
  ```js
156
960
  window.elements.ui.cartButton('header-cart', true);