@liquidcommerce/elements-sdk 2.7.0 → 2.7.1

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 (76) hide show
  1. package/README.md +83 -2750
  2. package/dist/index.checkout.esm.js +6877 -6825
  3. package/dist/index.esm.js +11384 -10940
  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/pubsub/interfaces/checkout.interface.d.ts +1 -0
  7. package/dist/types/enums/core.enum.d.ts +11 -0
  8. package/dist/types/interfaces/configs/product-list.interface.d.ts +2 -2
  9. package/dist/types/modules/address/address-input.component.d.ts +11 -0
  10. package/dist/types/modules/product-list/components/card-components/index.d.ts +3 -0
  11. package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +8 -0
  12. package/dist/types/modules/product-list/components/card-components/product-fulfillments.d.ts +2 -0
  13. package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +13 -0
  14. package/dist/types/modules/product-list/components/card-components/product-title.d.ts +6 -0
  15. package/dist/types/modules/product-list/components/index.d.ts +1 -0
  16. package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +5 -1
  17. package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +28 -0
  18. package/dist/types/modules/product-list/components/product-list-retailers.component.d.ts +10 -2
  19. package/dist/types/modules/product-list/product-list-card.component.d.ts +0 -5
  20. package/dist/types/modules/product-list/product-list.commands.d.ts +11 -2
  21. package/dist/types/modules/product-list/product-list.interface.d.ts +1 -0
  22. package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +11 -2
  23. package/docs/gitbook/actions.md +160 -0
  24. package/docs/gitbook/address.md +48 -0
  25. package/docs/gitbook/cart.md +65 -0
  26. package/docs/gitbook/checkout.md +131 -0
  27. package/docs/gitbook/events.md +137 -0
  28. package/docs/gitbook/overview.md +166 -0
  29. package/docs/gitbook/product.md +64 -0
  30. package/docs/gitbook/quick-start-guide.md +393 -0
  31. package/docs/v1/README.md +210 -0
  32. package/docs/v1/api/actions/address-actions.md +281 -0
  33. package/docs/v1/api/actions/cart-actions.md +337 -0
  34. package/docs/v1/api/actions/checkout-actions.md +387 -0
  35. package/docs/v1/api/actions/product-actions.md +115 -0
  36. package/docs/v1/api/client.md +482 -0
  37. package/docs/v1/api/configuration.md +1 -0
  38. package/docs/v1/api/injection-methods.md +247 -0
  39. package/docs/v1/api/typescript-types.md +1 -0
  40. package/docs/v1/api/ui-helpers.md +200 -0
  41. package/docs/v1/examples/advanced-patterns.md +96 -0
  42. package/docs/v1/examples/checkout-flow.md +91 -0
  43. package/docs/v1/examples/custom-theming.md +63 -0
  44. package/docs/v1/examples/multi-product-page.md +90 -0
  45. package/docs/v1/examples/simple-product-page.md +89 -0
  46. package/docs/v1/getting-started/concepts.md +507 -0
  47. package/docs/v1/getting-started/installation.md +328 -0
  48. package/docs/v1/getting-started/quick-start.md +405 -0
  49. package/docs/v1/guides/address-component.md +431 -0
  50. package/docs/v1/guides/best-practices.md +324 -0
  51. package/docs/v1/guides/cart-component.md +737 -0
  52. package/docs/v1/guides/checkout-component.md +672 -0
  53. package/docs/v1/guides/events.md +191 -0
  54. package/docs/v1/guides/product-component.md +686 -0
  55. package/docs/v1/guides/product-list-component.md +598 -0
  56. package/docs/v1/guides/theming.md +216 -0
  57. package/docs/v1/integration/angular.md +39 -0
  58. package/docs/v1/integration/laravel.md +41 -0
  59. package/docs/v1/integration/nextjs.md +60 -0
  60. package/docs/v1/integration/proxy-setup.md +89 -0
  61. package/docs/v1/integration/react.md +64 -0
  62. package/docs/v1/integration/vanilla-js.md +84 -0
  63. package/docs/v1/integration/vue.md +34 -0
  64. package/docs/v1/reference/browser-support.md +35 -0
  65. package/docs/v1/reference/error-handling.md +70 -0
  66. package/docs/v1/reference/performance.md +54 -0
  67. package/docs/v1/reference/troubleshooting.md +64 -0
  68. package/package.json +1 -1
  69. package/docs/ACTIONS.md +0 -1301
  70. package/docs/BROWSER_SUPPORT.md +0 -279
  71. package/docs/CONFIGURATION.md +0 -997
  72. package/docs/DOCUMENTATION_INDEX.md +0 -319
  73. package/docs/EVENTS.md +0 -798
  74. package/docs/PROXY.md +0 -228
  75. package/docs/THEMING.md +0 -681
  76. package/docs/TROUBLESHOOTING.md +0 -793
@@ -0,0 +1,387 @@
1
+ # Checkout Actions API
2
+
3
+ Checkout actions allow you to programmatically control the checkout flow.
4
+
5
+ ## Navigation Actions
6
+
7
+ ### actions.checkout.openCheckout()
8
+
9
+ ```typescript
10
+ openCheckout(): void
11
+ ```
12
+
13
+ Opens the checkout drawer or navigates to checkout page.
14
+
15
+ ```javascript
16
+ window.elements.actions.checkout.openCheckout();
17
+ ```
18
+
19
+ ### actions.checkout.closeCheckout()
20
+
21
+ ```typescript
22
+ closeCheckout(): void
23
+ ```
24
+
25
+ Closes the checkout drawer.
26
+
27
+ ```javascript
28
+ window.elements.actions.checkout.closeCheckout();
29
+ ```
30
+
31
+ ### actions.checkout.toggleCheckout()
32
+
33
+ ```typescript
34
+ toggleCheckout(): void
35
+ ```
36
+
37
+ Toggles checkout open/closed.
38
+
39
+ ```javascript
40
+ window.elements.actions.checkout.toggleCheckout();
41
+ ```
42
+
43
+ ### actions.checkout.exitCheckout()
44
+
45
+ ```typescript
46
+ exitCheckout(): void
47
+ ```
48
+
49
+ Navigates away from checkout (requires `exitUrl` configuration).
50
+
51
+ ```javascript
52
+ window.elements.actions.checkout.exitCheckout();
53
+ ```
54
+
55
+ ## Product Actions
56
+
57
+ ### actions.checkout.addProduct()
58
+
59
+ ```typescript
60
+ addProduct(params: IAddProductParams[], openCheckout?: boolean): Promise<void>
61
+ ```
62
+
63
+ Add products directly to checkout, bypassing the cart.
64
+
65
+ ```javascript
66
+ await window.elements.actions.checkout.addProduct([
67
+ {
68
+ identifier: '00619947000020',
69
+ fulfillmentType: 'shipping',
70
+ quantity: 1
71
+ }
72
+ ], true); // Open checkout after adding
73
+ ```
74
+
75
+ ## Promo & Gift Card Actions
76
+
77
+ ### actions.checkout.applyPromoCode()
78
+
79
+ ```typescript
80
+ applyPromoCode(promoCode: string): Promise<void>
81
+ ```
82
+
83
+ Apply a promo code during checkout.
84
+
85
+ ```javascript
86
+ await window.elements.actions.checkout.applyPromoCode('WELCOME10');
87
+ ```
88
+
89
+ ### actions.checkout.removePromoCode()
90
+
91
+ ```typescript
92
+ removePromoCode(): Promise<void>
93
+ ```
94
+
95
+ Remove the active promo code.
96
+
97
+ ```javascript
98
+ await window.elements.actions.checkout.removePromoCode();
99
+ ```
100
+
101
+ ### actions.checkout.applyGiftCard()
102
+
103
+ ```typescript
104
+ applyGiftCard(code: string): Promise<void>
105
+ ```
106
+
107
+ Apply a gift card.
108
+
109
+ ```javascript
110
+ await window.elements.actions.checkout.applyGiftCard('GIFT-1234-5678-9012');
111
+ ```
112
+
113
+ ### actions.checkout.removeGiftCard()
114
+
115
+ ```typescript
116
+ removeGiftCard(code: string): Promise<void>
117
+ ```
118
+
119
+ Remove a gift card.
120
+
121
+ ```javascript
122
+ await window.elements.actions.checkout.removeGiftCard('GIFT-1234-5678-9012');
123
+ ```
124
+
125
+ ## Toggle Actions
126
+
127
+ ### actions.checkout.toggleIsGift()
128
+
129
+ ```typescript
130
+ toggleIsGift(active?: boolean): Promise<void>
131
+ ```
132
+
133
+ Enable/disable gift mode.
134
+
135
+ ```javascript
136
+ // Enable
137
+ await window.elements.actions.checkout.toggleIsGift(true);
138
+
139
+ // Disable
140
+ await window.elements.actions.checkout.toggleIsGift(false);
141
+
142
+ // Toggle
143
+ await window.elements.actions.checkout.toggleIsGift();
144
+ ```
145
+
146
+ ### actions.checkout.toggleBillingSameAsShipping()
147
+
148
+ ```typescript
149
+ toggleBillingSameAsShipping(active?: boolean): Promise<void>
150
+ ```
151
+
152
+ Set whether billing address matches shipping.
153
+
154
+ ```javascript
155
+ // Use shipping address for billing
156
+ await window.elements.actions.checkout.toggleBillingSameAsShipping(true);
157
+
158
+ // Use different billing address
159
+ await window.elements.actions.checkout.toggleBillingSameAsShipping(false);
160
+ ```
161
+
162
+ ### actions.checkout.toggleMarketingPreferences()
163
+
164
+ ```typescript
165
+ toggleMarketingPreferences(field: 'canEmail' | 'canSms', active: boolean): Promise<void>
166
+ ```
167
+
168
+ Set marketing opt-in preferences.
169
+
170
+ ```javascript
171
+ // Opt into email marketing
172
+ await window.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
173
+
174
+ // Opt into SMS marketing
175
+ await window.elements.actions.checkout.toggleMarketingPreferences('canSms', true);
176
+ ```
177
+
178
+ ## Form Update Actions
179
+
180
+ ### actions.checkout.updateCustomerInfo()
181
+
182
+ ```typescript
183
+ updateCustomerInfo(params: Record<CustomerFieldName, string>): void
184
+ ```
185
+
186
+ Pre-fill customer information.
187
+
188
+ **Available fields:**
189
+ - `firstName`, `lastName`
190
+ - `email`, `phone`
191
+ - `birthdate`, `addressTwo`
192
+ - `company`
193
+
194
+ ```javascript
195
+ window.elements.actions.checkout.updateCustomerInfo({
196
+ firstName: 'John',
197
+ lastName: 'Doe',
198
+ email: 'john@example.com',
199
+ phone: '+15551234567',
200
+ birthdate: '1990-01-01',
201
+ addressTwo: 'Apt 4B',
202
+ company: 'Acme Corp'
203
+ });
204
+ ```
205
+
206
+ ### actions.checkout.updateBillingInfo()
207
+
208
+ ```typescript
209
+ updateBillingInfo(params: Record<BillingFieldName, string>): void
210
+ ```
211
+
212
+ Pre-fill billing address.
213
+
214
+ **Available fields:**
215
+ - `firstName`, `lastName`
216
+ - `email`, `phone`, `company`
217
+ - `addressOne`, `addressTwo`
218
+ - `city`, `state`, `zipCode`
219
+
220
+ ```javascript
221
+ window.elements.actions.checkout.updateBillingInfo({
222
+ firstName: 'John',
223
+ lastName: 'Doe',
224
+ email: 'john@example.com',
225
+ phone: '+15551234567',
226
+ company: 'Acme Corp',
227
+ addressOne: '123 Main St',
228
+ addressTwo: 'Apt 4B',
229
+ city: 'New York',
230
+ state: 'NY',
231
+ zipCode: '10001'
232
+ });
233
+ ```
234
+
235
+ ### actions.checkout.updateGiftInfo()
236
+
237
+ ```typescript
238
+ updateGiftInfo(params: Record<GiftFieldName, string>): void
239
+ ```
240
+
241
+ Pre-fill gift recipient information.
242
+
243
+ **Available fields:**
244
+ - `firstName`, `lastName`
245
+ - `email`, `phone`
246
+ - `message`, `addressTwo`
247
+
248
+ ```javascript
249
+ window.elements.actions.checkout.updateGiftInfo({
250
+ firstName: 'Jane',
251
+ lastName: 'Smith',
252
+ email: 'jane@example.com',
253
+ phone: '+15559876543',
254
+ addressTwo: 'Suite 200',
255
+ message: 'Happy Birthday!',
256
+ });
257
+ ```
258
+
259
+ ## Data Retrieval
260
+
261
+ ### actions.checkout.getDetails()
262
+
263
+ ```typescript
264
+ getDetails(): ICheckoutDetailsEventData
265
+ ```
266
+
267
+ Retrieve current checkout information.
268
+
269
+ ```javascript
270
+ const checkout = window.elements.actions.checkout.getDetails();
271
+
272
+ console.log(`Cart ID: ${checkout.cartId}`);
273
+ console.log(`Total: $${checkout.amounts.total / 100}`);
274
+ console.log(`Items: ${checkout.items.length}`);
275
+ console.log(`Is Gift: ${checkout.isGift}`);
276
+ ```
277
+
278
+ **Returns:**
279
+
280
+ ```typescript
281
+ interface ICheckoutDetailsEventData {
282
+ cartId: string;
283
+ items: ICheckoutItem[];
284
+ amounts: {
285
+ subtotal: number;
286
+ tax: number;
287
+ shipping: number;
288
+ tip: number;
289
+ total: number;
290
+ };
291
+ customer: ICustomerInfo;
292
+ shippingAddress: IAddress;
293
+ billingAddress?: IAddress;
294
+ isGift: boolean;
295
+ giftRecipient?: IGiftRecipient;
296
+ promoCode?: IPromoCode;
297
+ giftCards: IGiftCard[];
298
+ // ... additional fields
299
+ }
300
+ ```
301
+
302
+ ## Use Cases
303
+
304
+ ### Pre-fill for Logged-In Users
305
+
306
+ ```javascript
307
+ window.addEventListener('lce:actions.checkout_opened', () => {
308
+ if (userIsLoggedIn) {
309
+ window.elements.actions.checkout.updateCustomerInfo({
310
+ firstName: currentUser.firstName,
311
+ lastName: currentUser.lastName,
312
+ email: currentUser.email,
313
+ phone: currentUser.phone
314
+ });
315
+ }
316
+ });
317
+ ```
318
+
319
+ ### Track Checkout Progress
320
+
321
+ ```javascript
322
+ window.addEventListener('lce:actions.checkout_customer_information_updated', () => {
323
+ gtag('event', 'checkout_progress', { step: 'customer_info' });
324
+ });
325
+
326
+ window.addEventListener('lce:actions.checkout_submit_started', () => {
327
+ gtag('event', 'checkout_progress', { step: 'payment' });
328
+ });
329
+
330
+ window.addEventListener('lce:actions.checkout_submit_completed', (event) => {
331
+ const { orderId, total } = event.detail.data;
332
+
333
+ gtag('event', 'purchase', {
334
+ transaction_id: orderId,
335
+ value: total / 100,
336
+ currency: 'USD'
337
+ });
338
+ });
339
+ ```
340
+
341
+ ### Gift Flow
342
+
343
+ ```javascript
344
+ document.getElementById('gift-checkbox').addEventListener('change', async (e) => {
345
+ await window.elements.actions.checkout.toggleIsGift(e.target.checked);
346
+
347
+ if (e.target.checked) {
348
+ showGiftForm();
349
+ } else {
350
+ hideGiftForm();
351
+ }
352
+ });
353
+ ```
354
+
355
+ ### Auto-Apply Campaign Codes
356
+
357
+ ```javascript
358
+ const params = new URLSearchParams(window.location.search);
359
+ const campaignCode = params.get('promo');
360
+
361
+ if (campaignCode) {
362
+ window.addEventListener('lce:actions.checkout_opened', async () => {
363
+ try {
364
+ await window.elements.actions.checkout.applyPromoCode(campaignCode);
365
+ } catch (error) {
366
+ console.log('Invalid campaign code');
367
+ }
368
+ });
369
+ }
370
+ ```
371
+
372
+ ## Events
373
+
374
+ Checkout actions trigger numerous events. See [Checkout Events](../../guides/events.md#checkout-events) for complete list.
375
+
376
+ Key events:
377
+ - `checkout_opened`, `checkout_closed`
378
+ - `checkout_customer_information_updated`
379
+ - `checkout_submit_started`, `checkout_submit_completed`, `checkout_submit_failed`
380
+ - `checkout_promo_code_applied`, `checkout_promo_code_failed`
381
+ - `checkout_gift_card_applied`, `checkout_gift_card_failed`
382
+
383
+ ## See Also
384
+
385
+ - [Checkout Component Guide](../../guides/checkout-component.md)
386
+ - [Checkout Events](../../guides/events.md#checkout-events)
387
+ - [Cart Actions](./cart-actions.md)
@@ -0,0 +1,115 @@
1
+ # Product Actions API
2
+
3
+ Product actions allow you to programmatically retrieve product information.
4
+
5
+ ## actions.product.getDetails()
6
+
7
+ Retrieve details of a loaded product.
8
+
9
+ ### Signature
10
+
11
+ ```typescript
12
+ getDetails(identifier: string): IBaseProductEventData
13
+ ```
14
+
15
+ ### Parameters
16
+
17
+ | Parameter | Type | Required | Description |
18
+ |--------------|--------|----------|-------------------------|
19
+ | `identifier` | string | Yes | Product UPC, SKU, or ID |
20
+
21
+ ### Returns
22
+
23
+ ```typescript
24
+ interface IBaseProductEventData {
25
+ identifier: string;
26
+ name: string;
27
+ description: string;
28
+ price: number; // in cents
29
+ selectedSize: IProductSize;
30
+ selectedFulfillmentType: FulfillmentType;
31
+ selectedRetailer: IRetailer;
32
+ quantity: number;
33
+ images: string[];
34
+ brand: string;
35
+ category: string;
36
+ // ... additional fields
37
+ }
38
+ ```
39
+
40
+ ### Example
41
+
42
+ ```javascript
43
+ const productData = window.elements.actions.product.getDetails('00619947000020');
44
+
45
+ console.log(productData.name); // "Premium Whiskey"
46
+ console.log(productData.price / 100); // 49.99
47
+ console.log(productData.selectedSize.name); // "750ml"
48
+ console.log(productData.quantity); // 1
49
+ ```
50
+
51
+ ### Errors
52
+
53
+ **Throws `SDKError` if:**
54
+ - Identifier is empty or invalid
55
+ - Product has not been loaded yet
56
+ - Product does not exist
57
+
58
+ ```javascript
59
+ try {
60
+ const data = window.elements.actions.product.getDetails('invalid_id');
61
+ } catch (error) {
62
+ console.error('Product not found:', error.message);
63
+ }
64
+ ```
65
+
66
+ ### Use Cases
67
+
68
+ #### Display Product Info Elsewhere
69
+
70
+ ```javascript
71
+ const product = window.elements.actions.product.getDetails('00619947000020');
72
+
73
+ document.getElementById('product-name').textContent = product.name;
74
+ document.getElementById('product-price').textContent = `$${product.price / 100}`;
75
+ ```
76
+
77
+ #### Sync with Analytics
78
+
79
+ ```javascript
80
+ window.addEventListener('lce:actions.product_loaded', () => {
81
+ const product = window.elements.actions.product.getDetails('00619947000020');
82
+
83
+ gtag('event', 'view_item', {
84
+ items: [{
85
+ item_id: product.identifier,
86
+ item_name: product.name,
87
+ price: product.price / 100,
88
+ item_brand: product.brand
89
+ }]
90
+ });
91
+ });
92
+ ```
93
+
94
+ #### Custom Product Comparison
95
+
96
+ ```javascript
97
+ const product1 = window.elements.actions.product.getDetails('00619947000020');
98
+ const product2 = window.elements.actions.product.getDetails('08504405135');
99
+
100
+ if (product1.price < product2.price) {
101
+ console.log(`${product1.name} is cheaper`);
102
+ }
103
+ ```
104
+
105
+ ## Notes
106
+
107
+ - Product must be injected and loaded before calling `getDetails()`
108
+ - Data is synchronous - returns immediately
109
+ - Prices are always in cents (divide by 100 for dollars)
110
+ - Selected values reflect current user selection in the component
111
+
112
+ ## See Also
113
+
114
+ - [Product Component Guide](../../guides/product-component.md)
115
+ - [Product Events](../../guides/events.md#product-events)