@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,393 @@
1
+ # Quick Start Guide (Auto-Setup)
2
+
3
+ Most partners use the auto-setup approach because it is the fastest path to production. This guide covers the full data-attribute setup and all supported combinations.
4
+
5
+ ## 1) Main script tag
6
+ The main SDK auto-initializes when it finds a script tag with `data-liquid-commerce-elements`.
7
+
8
+ ```html
9
+ <script
10
+ defer
11
+ data-liquid-commerce-elements
12
+ data-token="YOUR_API_KEY"
13
+ data-env="production"
14
+ type="text/javascript"
15
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
16
+ ></script>
17
+ ```
18
+
19
+ ### Core configuration
20
+ **Attribute:** `data-liquid-commerce-elements`
21
+ Marks the script tag for auto-initialization.
22
+
23
+ **Attribute:** `data-token` (required)
24
+ Your API key.
25
+
26
+ **Attribute:** `data-env` (optional)
27
+ `development`, `staging`, or `production` (default: `production`).
28
+
29
+ ## 2) Product injection options
30
+ You can inject products in three different ways. All can be used together.
31
+
32
+ ### A) Paired attributes on the main script tag
33
+ Use `data-product-*` with `data-container-*` pairs.
34
+
35
+ **Attribute:** `data-product-*` + `data-container-*`
36
+ Pairs product identifiers to container IDs by matching the numeric suffix.
37
+
38
+ ```html
39
+ <script
40
+ defer
41
+ data-liquid-commerce-elements
42
+ data-token="YOUR_API_KEY"
43
+ data-env="production"
44
+ data-container-1="product-1"
45
+ data-product-1="00619947000020"
46
+ data-container-2="product-2"
47
+ data-product-2="08504405135"
48
+ type="text/javascript"
49
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
50
+ ></script>
51
+
52
+ <div id="product-1"></div>
53
+ <div id="product-2"></div>
54
+ ```
55
+
56
+ ### B) Attributed product elements
57
+ Any `div` with `data-lce-product` is treated as a product container.
58
+
59
+ **Attribute:** `data-lce-product`
60
+ Injects a product into the element and auto-generates a container ID.
61
+
62
+ ```html
63
+ <div data-lce-product="00619947000020"></div>
64
+ <div data-lce-product="08504405135"></div>
65
+ ```
66
+
67
+ The SDK auto-generates unique container IDs for these elements.
68
+
69
+ ### C) JSON script tag
70
+ Provide an array of objects with `containerId` and `identifier`.
71
+
72
+ **Attribute:** `data-liquid-commerce-elements-products`
73
+ Reads a JSON array of product definitions.
74
+
75
+ ```html
76
+ <script data-liquid-commerce-elements-products type="application/json">
77
+ [
78
+ { "containerId": "product-1", "identifier": "00619947000020" },
79
+ { "containerId": "product-2", "identifier": "08504405135" }
80
+ ]
81
+ </script>
82
+ ```
83
+
84
+ ## 3) Cart options (auto-UI + custom UI)
85
+ Cart buttons are configured from the main script tag.
86
+
87
+ ### Basic cart button
88
+ **Attribute:** `data-cart-button`
89
+ Renders a cart button in the specified container (by ID or selector).
90
+ ```html
91
+ <script
92
+ defer
93
+ data-liquid-commerce-elements
94
+ data-token="YOUR_API_KEY"
95
+ data-cart-button="header-cart"
96
+ type="text/javascript"
97
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
98
+ ></script>
99
+
100
+ <div id="header-cart"></div>
101
+ ```
102
+
103
+ ### Cart button with badge
104
+ **Attribute:** `data-cart-badge-button`
105
+ Renders a cart button with item count badge.
106
+ ```html
107
+ <script
108
+ defer
109
+ data-liquid-commerce-elements
110
+ data-token="YOUR_API_KEY"
111
+ data-cart-badge-button="header-cart"
112
+ type="text/javascript"
113
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
114
+ ></script>
115
+ ```
116
+
117
+ ### Floating cart button
118
+ Provide the attribute with no value.
119
+
120
+ **Attribute:** `data-cart-button` (no value)
121
+ Creates a floating cart button.
122
+
123
+ ```html
124
+ <script
125
+ defer
126
+ data-liquid-commerce-elements
127
+ data-token="YOUR_API_KEY"
128
+ data-cart-button
129
+ type="text/javascript"
130
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
131
+ ></script>
132
+ ```
133
+
134
+ ### Positioning cart buttons
135
+ You can position the cart button relative to any element using:
136
+ - `inside:` (default)
137
+ - `above:`
138
+ - `below:`
139
+ - `replace:`
140
+
141
+ ```html
142
+ <script
143
+ defer
144
+ data-liquid-commerce-elements
145
+ data-token="YOUR_API_KEY"
146
+ data-cart-button="above:.nav"
147
+ type="text/javascript"
148
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
149
+ ></script>
150
+ ```
151
+
152
+ ### Mobile-specific cart buttons
153
+ Use the mobile attributes to target mobile placement separately:
154
+ - `data-cart-mobile-button`
155
+ - `data-cart-mobile-badge-button`
156
+
157
+ **Attribute:** `data-cart-mobile-button`
158
+ Places a mobile-specific cart button.
159
+
160
+ **Attribute:** `data-cart-mobile-badge-button`
161
+ Places a mobile-specific cart button with badge.
162
+
163
+ ```html
164
+ <script
165
+ defer
166
+ data-liquid-commerce-elements
167
+ data-token="YOUR_API_KEY"
168
+ data-cart-mobile-button="inside:#mobile-nav"
169
+ type="text/javascript"
170
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
171
+ ></script>
172
+ ```
173
+
174
+ ### Hide cart buttons entirely
175
+ **Attribute:** `data-cart-button-hidden`
176
+ Disables auto-created cart buttons.
177
+ ```html
178
+ <script
179
+ defer
180
+ data-liquid-commerce-elements
181
+ data-token="YOUR_API_KEY"
182
+ data-cart-button-hidden
183
+ type="text/javascript"
184
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
185
+ ></script>
186
+ ```
187
+
188
+ ### Cart toggle buttons (custom UI)
189
+ Any element with `data-lce-cart-toggle-button` will toggle the cart drawer.
190
+
191
+ **Attribute:** `data-lce-cart-toggle-button`
192
+ Toggles the cart drawer on click.
193
+
194
+ ```html
195
+ <button data-lce-cart-toggle-button>View Cart</button>
196
+ ```
197
+
198
+ ### Cart items count (custom UI)
199
+ Use `data-lce-cart-items-count` on any element to show item count.
200
+
201
+ **Attribute:** `data-lce-cart-items-count`
202
+ Renders a live cart item count.
203
+
204
+ ```html
205
+ <span data-lce-cart-items-count></span>
206
+ ```
207
+
208
+ By default it hides when the cart is empty. To keep it visible with `0`, set:
209
+
210
+ ```html
211
+ <span data-lce-cart-items-count="keep-zero"></span>
212
+ ```
213
+
214
+ ## 4) Checkout (hosted injection + checkout-only build)
215
+ Hosted checkout needs two things working together:
216
+ 1) A **checkout URL** so the cart can redirect to your hosted checkout page.
217
+ 2) A **checkout param name** so the hosted page can read the checkout ID from the URL and load it.
218
+
219
+ ### Checkout container
220
+ **Attribute:** `data-lce-checkout`
221
+ Injects the hosted checkout into this container on the checkout page.
222
+ ```html
223
+ <div data-lce-checkout></div>
224
+ ```
225
+
226
+ ### Hide checkout header
227
+ **Attribute:** `hide-header`
228
+ Hides the SDK header so you can render your own header and layout.
229
+ ```html
230
+ <div data-lce-checkout hide-header></div>
231
+ ```
232
+
233
+ ### Exit checkout button
234
+ **Attribute:** `data-lce-exit-checkout`
235
+ Lets you build your own “Exit checkout” UI. The SDK wires the click to the checkout exit action.
236
+ ```html
237
+ <button data-lce-exit-checkout>Exit checkout</button>
238
+ ```
239
+
240
+ ### Checkout ID from query params (required for hosted checkout)
241
+ Use `data-checkout-param` on the script tag to control which query param provides the checkout ID.
242
+ **Attribute:** `data-checkout-param`
243
+ Sets the query parameter name (must start with `lce_`). The hosted page reads this param to load the checkout.
244
+
245
+ ```html
246
+ <script
247
+ defer
248
+ data-liquid-commerce-elements
249
+ data-token="YOUR_API_KEY"
250
+ data-checkout-param="lce_checkout"
251
+ type="text/javascript"
252
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
253
+ ></script>
254
+ ```
255
+
256
+ Notes:
257
+ - Query parameter names must start with `lce_` or they are ignored.
258
+ - Default is `lce_checkout` if not provided.
259
+
260
+ ### Checkout redirect URL (required for hosted checkout)
261
+ **Attribute:** `data-checkout-url`
262
+ Defines the hosted checkout page URL pattern. The cart drawer redirects to this URL and injects the checkout token into `{token}`.
263
+
264
+ ```html
265
+ <script
266
+ defer
267
+ data-liquid-commerce-elements
268
+ data-token="YOUR_API_KEY"
269
+ data-env="production"
270
+ data-checkout-url="https://yoursite.com/checkout?lce_checkout={token}"
271
+ data-checkout-param="lce_checkout"
272
+ type="text/javascript"
273
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
274
+ ></script>
275
+ ```
276
+
277
+ ### Checkout-only auto-initialize
278
+ Use the checkout-only build when you only need checkout on the hosted checkout page. It supports the same hosted-checkout attributes (`data-lce-checkout`, `data-checkout-param`, `hide-header`, `data-lce-exit-checkout`) but ships a smaller script for faster load time.
279
+
280
+ ```html
281
+ <script
282
+ defer
283
+ data-liquid-commerce-elements
284
+ data-token="YOUR_API_KEY"
285
+ data-env="production"
286
+ type="text/javascript"
287
+ src="https://assets-elements.liquidcommerce.us/checkout/elements.js"
288
+ ></script>
289
+ ```
290
+
291
+ Supported attributes on checkout-only script:
292
+ - `data-token` (required)
293
+ - `data-env` (optional)
294
+ - `data-debug-mode` (optional, non-production only)
295
+ - `data-checkout-url` (optional)
296
+
297
+ The checkout-only build also supports `data-lce-checkout` containers and `data-checkout-param` query parameter handling.
298
+
299
+ ## 5) Auto actions from query parameters
300
+ Auto-init can read query params to add a product or apply a promo code.
301
+
302
+ ### Add product to cart via query params
303
+ - `data-product-param` (required)
304
+ - `data-product-fulfillment-type-param` (optional, `shipping` or `onDemand`)
305
+
306
+ **Attribute:** `data-product-param`
307
+ Name of query param that contains the product identifier (must start with `lce_`).
308
+
309
+ **Attribute:** `data-product-fulfillment-type-param`
310
+ Name of query param that contains fulfillment type (must start with `lce_`).
311
+
312
+ ```html
313
+ <script
314
+ defer
315
+ data-liquid-commerce-elements
316
+ data-token="YOUR_API_KEY"
317
+ data-product-param="lce_product"
318
+ data-product-fulfillment-type-param="lce_fulfillment"
319
+ type="text/javascript"
320
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
321
+ ></script>
322
+ ```
323
+
324
+ Example URL:
325
+ ```
326
+ https://yoursite.com?lce_product=00619947000020&lce_fulfillment=shipping
327
+ ```
328
+
329
+ ### Apply promo code via query params
330
+ - `data-promo-code-param`
331
+
332
+ **Attribute:** `data-promo-code-param`
333
+ Name of query param that contains the promo code (must start with `lce_`).
334
+
335
+ ```html
336
+ <script
337
+ defer
338
+ data-liquid-commerce-elements
339
+ data-token="YOUR_API_KEY"
340
+ data-promo-code-param="lce_promo"
341
+ type="text/javascript"
342
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
343
+ ></script>
344
+ ```
345
+
346
+ Example URL:
347
+ ```
348
+ https://yoursite.com?lce_promo=SUMMER20
349
+ ```
350
+
351
+ Notes:
352
+ - Query parameter names must start with `lce_` or they are ignored.
353
+
354
+ ## 6) Advanced script options (optional)
355
+ These are supported but not required for most implementations.
356
+
357
+ ### Promo ticker
358
+ All four of these must be present to enable the promo ticker.
359
+
360
+ **Attributes:** `data-promo-code`, `data-promo-text`, `data-promo-separator`, `data-promo-active-from`, `data-promo-active-until`
361
+ Enables the promo ticker. `data-promo-text` is pipe-separated (e.g. `"Text A|Text B"`).
362
+
363
+ ```html
364
+ <script
365
+ defer
366
+ data-liquid-commerce-elements
367
+ data-token="YOUR_API_KEY"
368
+ data-env="production"
369
+ data-promo-code="SUMMER20"
370
+ data-promo-text="20% Off|Free shipping over $50"
371
+ data-promo-separator="•"
372
+ data-promo-active-from="2026-06-01T00:00:00Z"
373
+ data-promo-active-until="2026-08-31T23:59:59Z"
374
+ type="text/javascript"
375
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
376
+ ></script>
377
+ ```
378
+
379
+ ### Development config
380
+ For local development or testing, you can inject development overrides via a JSON script tag:
381
+
382
+ **Attribute:** `data-liquid-commerce-elements-development`
383
+ Reads JSON for development overrides.
384
+
385
+ ```html
386
+ <script data-liquid-commerce-elements-development type="application/json">
387
+ {
388
+ "customApiUrl": "http://localhost:3000/api",
389
+ "paymentMethodId": "pm_test_123",
390
+ "openShadowDom": true
391
+ }
392
+ </script>
393
+ ```
@@ -0,0 +1,210 @@
1
+ # Elements SDK v1 Documentation
2
+
3
+ Welcome to the comprehensive documentation for the LiquidCommerce Elements SDK v1.
4
+
5
+ ## What is Elements SDK?
6
+
7
+ The Elements SDK is a Web Components-based e-commerce SDK that allows you to add product displays, shopping carts, and checkout flows to any website with minimal code.
8
+
9
+ ## Quick Links
10
+
11
+ - **[Installation](./getting-started/installation.md)** - Get started in minutes
12
+ - **[Quick Start](./getting-started/quick-start.md)** - Build your first product page
13
+ - **[API Reference](./api/client.md)** - Complete API documentation
14
+
15
+ ## Documentation Sections
16
+
17
+ ### Getting Started
18
+
19
+ Essential guides for new users:
20
+
21
+ - **[Installation](./getting-started/installation.md)** - CDN, NPM, and framework integration
22
+ - **[Quick Start](./getting-started/quick-start.md)** - Your first product page in 5 minutes
23
+ - **[Core Concepts](./getting-started/concepts.md)** - Understand how the SDK works
24
+
25
+ ### Component Guides
26
+
27
+ In-depth guides for each major component:
28
+
29
+ - **[Product Component](./guides/product-component.md)** - Display products with add-to-cart functionality
30
+ - **[Cart Component](./guides/cart-component.md)** - Shopping cart and item management
31
+ - **[Checkout Component](./guides/checkout-component.md)** - Complete purchase flow
32
+ - **[Address Component](./guides/address-component.md)** - Delivery location management
33
+ - **[Product List Component](./guides/product-list-component.md)** - Filterable product catalogs
34
+ - **[Theming](./guides/theming.md)** - Customize appearance and branding
35
+ - **[Events](./guides/events.md)** - Event system and subscriptions
36
+ - **[Best Practices](./guides/best-practices.md)** - Patterns, tips, and recommendations
37
+
38
+ ### API Reference
39
+
40
+ Complete API documentation:
41
+
42
+ **Core API:**
43
+ - **[Client API](./api/client.md)** - Main SDK client interface
44
+ - **[Injection Methods](./api/injection-methods.md)** - Component injection
45
+ - **[UI Helpers](./api/ui-helpers.md)** - Cart buttons and UI elements
46
+ - **[Configuration](./api/configuration.md)** - All configuration options
47
+ - **[TypeScript Types](./api/typescript-types.md)** - Type definitions
48
+
49
+ **Actions API:**
50
+ - **[Product Actions](./api/actions/product-actions.md)** - `actions.product.*`
51
+ - **[Address Actions](./api/actions/address-actions.md)** - `actions.address.*`
52
+ - **[Cart Actions](./api/actions/cart-actions.md)** - `actions.cart.*`
53
+ - **[Checkout Actions](./api/actions/checkout-actions.md)** - `actions.checkout.*`
54
+
55
+ ### Architecture (To Be Done In Future Versions)
56
+
57
+ Deep dive into SDK internals:
58
+
59
+ - **[Overview](./architecture/overview.md)** - System architecture
60
+ - **[Initialization](./architecture/initialization.md)** - Phased initialization process
61
+ - **[State Management](./architecture/state-management.md)** - Store service and persistence
62
+ - **[Event System](./architecture/event-system.md)** - PubSub architecture
63
+ - **[Web Components](./architecture/web-components.md)** - Component factory and Shadow DOM
64
+ - **[Build System](./architecture/build-system.md)** - Bundles and tree-shaking
65
+
66
+ ### Framework Integration
67
+
68
+ Integration guides for popular frameworks:
69
+
70
+ - **[React](./integration/react.md)** - React integration patterns and hooks
71
+ - **[Next.js](./integration/nextjs.md)** - Next.js setup with SSR considerations
72
+ - **[Vue](./integration/vue.md)** - Vue component integration
73
+ - **[Angular](./integration/angular.md)** - Angular client-only setup
74
+ - **[Laravel](./integration/laravel.md)** - Blade + CDN integration
75
+ - **[Vanilla JavaScript](./integration/vanilla-js.md)** - Pure JavaScript integration
76
+ - **[Proxy Setup](./integration/proxy-setup.md)** - Ad blocker avoidance
77
+
78
+ ### Reference
79
+
80
+ Technical reference and troubleshooting:
81
+
82
+ - **[Browser Support](./reference/browser-support.md)** - Compatibility matrix
83
+ - **[Troubleshooting](./reference/troubleshooting.md)** - Common issues and solutions
84
+ - **[Error Handling](./reference/error-handling.md)** - Error types and debugging
85
+ - **[Performance](./reference/performance.md)** - Optimization tips and best practices
86
+
87
+ ### Examples
88
+
89
+ Practical examples with working code:
90
+
91
+ - **[Simple Product Page](./examples/simple-product-page.md)** - Basic PDP implementation
92
+ - **[Multi-Product Page](./examples/multi-product-page.md)** - Multiple products on one page
93
+ - **[Complete Checkout Flow](./examples/checkout-flow.md)** - Full e-commerce flow
94
+ - **[Custom Theming](./examples/custom-theming.md)** - Brand customization examples
95
+ - **[Advanced Patterns](./examples/advanced-patterns.md)** - Complex integration scenarios
96
+
97
+ ## Common Tasks
98
+
99
+ ### Adding a Product
100
+
101
+ **Declarative (HTML):**
102
+ ```html
103
+ <script
104
+ defer
105
+ data-liquid-commerce-elements
106
+ data-token="YOUR_API_KEY"
107
+ data-env="production"
108
+ data-container-1="product"
109
+ data-product-1="00619947000020"
110
+ type="text/javascript"
111
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
112
+ ></script>
113
+
114
+ <div id="product"></div>
115
+ ```
116
+
117
+ **Programmatic (JavaScript):**
118
+ ```javascript
119
+ const client = await Elements('YOUR_API_KEY', { env: 'production' });
120
+ await client.injectProductElement([
121
+ { containerId: 'product', identifier: '00619947000020' }
122
+ ]);
123
+ ```
124
+
125
+ ### Opening the Cart
126
+
127
+ ```javascript
128
+ window.elements.actions.cart.openCart();
129
+ ```
130
+
131
+ ### Adding to Cart Programmatically
132
+
133
+ ```javascript
134
+ await window.elements.actions.cart.addProduct([
135
+ {
136
+ identifier: '00619947000020',
137
+ fulfillmentType: 'shipping',
138
+ quantity: 1
139
+ }
140
+ ], true); // true = open cart after adding
141
+ ```
142
+
143
+ ### Listening for Events
144
+
145
+ ```javascript
146
+ window.addEventListener('lce:actions.cart_item_added', (event) => {
147
+ console.log('Item added to cart:', event.detail.data);
148
+ });
149
+ ```
150
+
151
+ ### Customizing Theme
152
+
153
+ ```javascript
154
+ const client = await Elements('YOUR_API_KEY', {
155
+ env: 'production',
156
+ customTheme: {
157
+ global: {
158
+ theme: {
159
+ primaryColor: '#007bff',
160
+ buttonCornerRadius: '8px'
161
+ }
162
+ }
163
+ }
164
+ });
165
+ ```
166
+
167
+ ## Key Concepts
168
+
169
+ ### Web Components
170
+ The SDK uses native Web Components for framework-agnostic integration and style encapsulation.
171
+
172
+ ### Shadow DOM
173
+ Components use Shadow DOM to prevent CSS conflicts and ensure consistent styling.
174
+
175
+ ### Auto-Initialization
176
+ When using the CDN, the SDK automatically initializes based on HTML data attributes.
177
+
178
+ ### Event-Driven
179
+ The SDK publishes events for all user interactions, allowing you to react to changes.
180
+
181
+ ### State Persistence
182
+ Cart and address data persist across sessions using localStorage with API fallback.
183
+
184
+ ## Browser Requirements
185
+
186
+ - Chrome 66+ (March 2018)
187
+ - Firefox 60+ (May 2018)
188
+ - Safari 12+ (September 2018)
189
+ - Edge 79+ (January 2020)
190
+
191
+ Requires Web Components and Shadow DOM support.
192
+
193
+ ## Support
194
+
195
+ For assistance, contact your LiquidCommerce representative.
196
+
197
+ ## Version History
198
+
199
+ This is the v1 documentation. Future versions will be documented in separate directories (`v2/`, `v3/`, etc.).
200
+
201
+ ## Contributing
202
+
203
+ Found an issue in the documentation? Contact your LiquidCommerce representative with suggestions.
204
+
205
+ ---
206
+
207
+ ## Navigation
208
+
209
+ - [← Back to Repository](../)
210
+ - [Getting Started →](./getting-started/installation.md)