@liquidcommerce/elements-sdk 2.6.7 → 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 (170) hide show
  1. package/README.md +83 -2519
  2. package/dist/index.checkout.esm.js +16086 -0
  3. package/dist/index.esm.js +16267 -13788
  4. package/dist/types/auto-initialize/checkout.d.ts +2 -0
  5. package/dist/types/auto-initialize/shared-utils.d.ts +27 -0
  6. package/dist/types/{elements-base-client.d.ts → clients/base.d.ts} +11 -1
  7. package/dist/types/clients/checkout.d.ts +13 -0
  8. package/dist/types/constants/core.constant.d.ts +5 -3
  9. package/dist/types/core/api/api-client.service.d.ts +0 -2
  10. package/dist/types/core/client/actions/base-action.service.d.ts +15 -0
  11. package/dist/types/core/client/actions/client-address-action.service.d.ts +18 -0
  12. package/dist/types/core/client/actions/client-cart-action.service.d.ts +37 -0
  13. package/dist/types/core/client/actions/client-checkout-action.service.d.ts +50 -0
  14. package/dist/types/core/client/actions/client-product-action.service.d.ts +12 -0
  15. package/dist/types/core/client/client-action.service.d.ts +6 -73
  16. package/dist/types/core/client/client-config.service.d.ts +3 -4
  17. package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +1 -0
  18. package/dist/types/core/store/interfaces/core.interface.d.ts +14 -1
  19. package/dist/types/core/store/interfaces/metadata.interface.d.ts +11 -0
  20. package/dist/types/core/store/interfaces/product-list.interface.d.ts +45 -0
  21. package/dist/types/core/store/interfaces/product.interface.d.ts +1 -0
  22. package/dist/types/core/store/store.constant.d.ts +4 -0
  23. package/dist/types/enums/core.enum.d.ts +14 -1
  24. package/dist/types/enums/index.d.ts +0 -1
  25. package/dist/types/index.checkout.d.ts +7 -0
  26. package/dist/types/index.checkout.umd.d.ts +4 -0
  27. package/dist/types/index.d.ts +2 -2
  28. package/dist/types/interfaces/api/checkout.interface.d.ts +2 -1
  29. package/dist/types/interfaces/api/product-list.interface.d.ts +13 -5
  30. package/dist/types/interfaces/configs/checkout.interface.d.ts +1 -0
  31. package/dist/types/interfaces/configs/global.interface.d.ts +4 -2
  32. package/dist/types/interfaces/configs/index.d.ts +1 -0
  33. package/dist/types/interfaces/configs/product-list.interface.d.ts +28 -0
  34. package/dist/types/interfaces/core.interface.d.ts +28 -6
  35. package/dist/types/modules/address/address-input.component.d.ts +11 -0
  36. package/dist/types/modules/address/styles/register-styles.d.ts +1 -0
  37. package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
  38. package/dist/types/modules/checkout/checkout.commands.d.ts +6 -2
  39. package/dist/types/modules/checkout/checkout.component.d.ts +2 -0
  40. package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +2 -0
  41. package/dist/types/modules/checkout/components/checkout-header.component.d.ts +1 -0
  42. package/dist/types/modules/checkout/styles/register-styles.d.ts +1 -0
  43. package/dist/types/modules/product/styles/register-styles.d.ts +1 -0
  44. package/dist/types/modules/product-list/components/card-components/index.d.ts +7 -0
  45. package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +8 -0
  46. package/dist/types/modules/product-list/components/card-components/product-button.d.ts +11 -0
  47. package/dist/types/modules/product-list/components/card-components/product-fulfillments.d.ts +12 -0
  48. package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +13 -0
  49. package/dist/types/modules/product-list/components/card-components/product-quantity-selector.d.ts +10 -0
  50. package/dist/types/modules/product-list/components/card-components/product-sizes-list.d.ts +9 -0
  51. package/dist/types/modules/product-list/components/card-components/product-title.d.ts +6 -0
  52. package/dist/types/modules/product-list/components/filter-components/index.d.ts +7 -0
  53. package/dist/types/modules/product-list/components/filter-components/product-list-apply-filter-button.d.ts +1 -0
  54. package/dist/types/modules/product-list/components/filter-components/product-list-chip.d.ts +5 -0
  55. package/dist/types/modules/product-list/components/filter-components/product-list-filters-chips.d.ts +13 -0
  56. package/dist/types/modules/product-list/components/filter-components/product-list-fulfillment-filter.d.ts +14 -0
  57. package/dist/types/modules/product-list/components/{product-list-filters-subcomponents/product-list-price-filter.components.d.ts → filter-components/product-list-price-filter.d.ts} +1 -1
  58. package/dist/types/modules/product-list/components/filter-components/product-list-toggle-filters.d.ts +13 -0
  59. package/dist/types/modules/product-list/components/index.d.ts +7 -3
  60. package/dist/types/modules/product-list/components/product-list-card-loading.component.d.ts +2 -1
  61. package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +10 -0
  62. package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +58 -37
  63. package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +28 -0
  64. package/dist/types/modules/product-list/components/product-list-retailers.component.d.ts +26 -0
  65. package/dist/types/modules/product-list/components/product-list-search.component.d.ts +22 -0
  66. package/dist/types/modules/product-list/product-list-card.component.d.ts +30 -0
  67. package/dist/types/modules/product-list/product-list.commands.d.ts +62 -3
  68. package/dist/types/modules/product-list/product-list.component.d.ts +16 -43
  69. package/dist/types/{enums/cloud.enum.d.ts → modules/product-list/product-list.constants.d.ts} +20 -1
  70. package/dist/types/modules/product-list/product-list.interface.d.ts +33 -24
  71. package/dist/types/modules/product-list/styles/product-list-card.style.d.ts +1 -0
  72. package/dist/types/modules/product-list/styles/product-list-filters.style.d.ts +1 -0
  73. package/dist/types/modules/product-list/styles/register-styles.d.ts +1 -0
  74. package/dist/types/modules/theme-provider/constants/component-groupings.d.ts +1 -0
  75. package/dist/types/modules/theme-provider/constants/css-variable-mappings.d.ts +1 -1
  76. package/dist/types/modules/theme-provider/services/style-registry.service.d.ts +16 -0
  77. package/dist/types/modules/theme-provider/services/stylesheet-generator.service.d.ts +0 -1
  78. package/dist/types/modules/theme-provider/styles/register-styles.d.ts +1 -0
  79. package/dist/types/modules/theme-provider/theme-provider.service.d.ts +2 -1
  80. package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +13 -1
  81. package/dist/types/modules/ui-components/input/index.d.ts +0 -1
  82. package/dist/types/modules/ui-components/input/input.component.d.ts +8 -1
  83. package/dist/types/modules/ui-components/modal/modal.component.d.ts +23 -0
  84. package/dist/types/modules/ui-components/styles/modal.style.d.ts +1 -0
  85. package/dist/types/modules/ui-components/ui.commands.d.ts +3 -1
  86. package/dist/types/static/icon/check.icon.d.ts +2 -0
  87. package/dist/types/static/icon/index.d.ts +1 -0
  88. package/docs/gitbook/actions.md +160 -0
  89. package/docs/gitbook/address.md +48 -0
  90. package/docs/gitbook/cart.md +65 -0
  91. package/docs/gitbook/checkout.md +131 -0
  92. package/docs/gitbook/events.md +137 -0
  93. package/docs/gitbook/overview.md +166 -0
  94. package/docs/gitbook/product.md +64 -0
  95. package/docs/gitbook/quick-start-guide.md +393 -0
  96. package/docs/v1/README.md +210 -0
  97. package/docs/v1/api/actions/address-actions.md +281 -0
  98. package/docs/v1/api/actions/cart-actions.md +337 -0
  99. package/docs/v1/api/actions/checkout-actions.md +387 -0
  100. package/docs/v1/api/actions/product-actions.md +115 -0
  101. package/docs/v1/api/client.md +482 -0
  102. package/docs/v1/api/configuration.md +1 -0
  103. package/docs/v1/api/injection-methods.md +247 -0
  104. package/docs/v1/api/typescript-types.md +1 -0
  105. package/docs/v1/api/ui-helpers.md +200 -0
  106. package/docs/v1/examples/advanced-patterns.md +96 -0
  107. package/docs/v1/examples/checkout-flow.md +91 -0
  108. package/docs/v1/examples/custom-theming.md +63 -0
  109. package/docs/v1/examples/multi-product-page.md +90 -0
  110. package/docs/v1/examples/simple-product-page.md +89 -0
  111. package/docs/v1/getting-started/concepts.md +507 -0
  112. package/docs/v1/getting-started/installation.md +328 -0
  113. package/docs/v1/getting-started/quick-start.md +405 -0
  114. package/docs/v1/guides/address-component.md +431 -0
  115. package/docs/v1/guides/best-practices.md +324 -0
  116. package/docs/v1/guides/cart-component.md +737 -0
  117. package/docs/v1/guides/checkout-component.md +672 -0
  118. package/docs/v1/guides/events.md +191 -0
  119. package/docs/v1/guides/product-component.md +686 -0
  120. package/docs/v1/guides/product-list-component.md +598 -0
  121. package/docs/v1/guides/theming.md +216 -0
  122. package/docs/v1/integration/angular.md +39 -0
  123. package/docs/v1/integration/laravel.md +41 -0
  124. package/docs/v1/integration/nextjs.md +60 -0
  125. package/docs/v1/integration/proxy-setup.md +89 -0
  126. package/docs/v1/integration/react.md +64 -0
  127. package/docs/v1/integration/vanilla-js.md +84 -0
  128. package/docs/v1/integration/vue.md +34 -0
  129. package/docs/v1/reference/browser-support.md +35 -0
  130. package/docs/v1/reference/error-handling.md +70 -0
  131. package/docs/v1/reference/performance.md +54 -0
  132. package/docs/v1/reference/troubleshooting.md +64 -0
  133. package/package.json +19 -12
  134. package/dist/types/modules/product-list/components/product-list-card.component.d.ts +0 -37
  135. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/index.d.ts +0 -6
  136. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-apply-filter-button.component.d.ts +0 -1
  137. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-delivery-options-filter.components.d.ts +0 -16
  138. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-search.component.d.ts +0 -16
  139. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-toggle-filters.components.d.ts +0 -18
  140. package/dist/types/modules/theme-provider/styles/address/index.d.ts +0 -1
  141. package/dist/types/modules/theme-provider/styles/cart/index.d.ts +0 -1
  142. package/dist/types/modules/theme-provider/styles/checkout/index.d.ts +0 -1
  143. package/dist/types/modules/theme-provider/styles/product/index.d.ts +0 -3
  144. package/dist/types/modules/theme-provider/styles/product-list/index.d.ts +0 -1
  145. package/dist/types/modules/theme-provider/styles/ui/index.d.ts +0 -3
  146. package/dist/types/modules/ui-components/input/birthdate-input.component.d.ts +0 -53
  147. package/docs/ACTIONS.md +0 -1300
  148. package/docs/BROWSER_SUPPORT.md +0 -279
  149. package/docs/CONFIGURATION.md +0 -853
  150. package/docs/DOCUMENTATION_INDEX.md +0 -311
  151. package/docs/EVENTS.md +0 -798
  152. package/docs/PROXY.md +0 -228
  153. package/docs/THEMING.md +0 -592
  154. package/docs/TROUBLESHOOTING.md +0 -793
  155. package/umd/elements.js +0 -1
  156. /package/dist/types/{auto-initialize.d.ts → auto-initialize/main.d.ts} +0 -0
  157. /package/dist/types/{elements-builder-client.d.ts → clients/builder.d.ts} +0 -0
  158. /package/dist/types/{elements-client-helper.d.ts → clients/helpers.d.ts} +0 -0
  159. /package/dist/types/{elements-client.d.ts → clients/main.d.ts} +0 -0
  160. /package/dist/types/modules/{theme-provider/styles/address → address/styles}/address.style.d.ts +0 -0
  161. /package/dist/types/modules/{theme-provider/styles/cart → cart/styles}/cart.style.d.ts +0 -0
  162. /package/dist/types/modules/{theme-provider/styles/checkout → checkout/styles}/checkout.style.d.ts +0 -0
  163. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/image-carousel.style.d.ts +0 -0
  164. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/product.style.d.ts +0 -0
  165. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/retailers.style.d.ts +0 -0
  166. /package/dist/types/modules/product-list/components/{product-list-filters-subcomponents/product-list-checkbox-filter.components.d.ts → filter-components/product-list-checkbox-filter.d.ts} +0 -0
  167. /package/dist/types/modules/{theme-provider/styles/product-list → product-list/styles}/product-list.style.d.ts +0 -0
  168. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/drawer.style.d.ts +0 -0
  169. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/loading.style.d.ts +0 -0
  170. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/promo-code-ticker.style.d.ts +0 -0
@@ -1,853 +0,0 @@
1
- # Configuration Reference
2
-
3
- Complete reference for all LiquidCommerce Elements SDK configuration options.
4
-
5
- ## Basic Configuration
6
-
7
- ```javascript
8
- const client = await Elements('YOUR_API_KEY', {
9
- env: 'production',
10
- debugMode: 'none',
11
- isBuilder: false,
12
- customTheme: {},
13
- proxy: {},
14
- promoTicker: []
15
- });
16
- ```
17
-
18
- ## Configuration Options
19
-
20
- ### `env` (required)
21
-
22
- **Type:** `'local' | 'development' | 'staging' | 'production'`
23
- **Default:** `'production'`
24
-
25
- Specifies the API environment to use.
26
-
27
- ```javascript
28
- env: 'production' // Live environment
29
- env: 'staging' // Pre-production testing
30
- env: 'development' // Development with extra logging
31
- env: 'local' // Local development
32
- ```
33
-
34
- **Environment URLs:**
35
- - `production`: `https://elements.liquidcommerce.us`
36
- - `staging`: `https://staging-elements.liquidcommerce.us`
37
- - `development`: `https://dev-elements.liquidcommerce.us`
38
- - `local`: `http://localhost:3000`
39
-
40
- ### `debugMode`
41
-
42
- **Type:** `'none' | 'console' | 'panel'`
43
- **Default:** `'none'`
44
-
45
- Controls logging and debugging output.
46
-
47
- ```javascript
48
- debugMode: 'none' // No logging (production)
49
- debugMode: 'console' // Console logs only
50
- debugMode: 'panel' // Visual debug panel + console
51
- ```
52
-
53
- **Debug panel features:**
54
- - Real-time event stream
55
- - API call inspector
56
- - State viewer
57
- - Performance metrics
58
-
59
- **Note:** Automatically disabled in production environment regardless of setting.
60
-
61
- ### `isBuilder`
62
-
63
- **Type:** `boolean`
64
- **Default:** `false`
65
-
66
- Enables builder mode for theme development and testing.
67
-
68
- ```javascript
69
- isBuilder: true // Enables builder.* methods
70
- ```
71
-
72
- **Builder mode provides:**
73
- - `client.builder.updateComponentGlobalConfigs()`
74
- - `client.builder.updateProductComponent()`
75
- - `client.builder.updateCartComponent()`
76
- - `client.builder.updateCheckoutComponent()`
77
- - `client.builder.updateAddressComponent()`
78
-
79
- **Use case:** Theme customization and testing.
80
-
81
- ### `customTheme`
82
-
83
- **Type:** `object`
84
- **Default:** `{}`
85
-
86
- Custom theme configuration. See [`THEMING.md`](./THEMING.md) for complete reference.
87
-
88
- ```javascript
89
- customTheme: {
90
- global: {
91
- colors: {
92
- primary: '#007bff',
93
- secondary: '#6c757d'
94
- },
95
- typography: {
96
- fontFamily: 'Inter, sans-serif',
97
- fontSize: '16px'
98
- },
99
- layout: {
100
- enablePersonalization: true,
101
- personalizationText: 'Personalize your product',
102
- personalizationCardStyle: 'outlined',
103
- allowPromoCodes: true,
104
- inputFieldStyle: 'outlined',
105
- poweredByMode: 'light' // Can be customized
106
- // Note: showPoweredBy cannot be customized (controlled by LiquidCommerce)
107
- }
108
- },
109
- product: { /* product theme */ },
110
- cart: { /* cart theme */ },
111
- checkout: { /* checkout theme */ },
112
- address: { /* address theme */ }
113
- }
114
- ```
115
-
116
- **Key Theme Categories:**
117
-
118
- - **`global`**: Affects all components (colors, fonts, personalization settings)
119
- - **`product`**: Product display customization
120
- - **`cart`**: Cart drawer and item display
121
- - **`checkout`**: Checkout flow and completion screen
122
- - **`address`**: Address input and selection
123
-
124
- **Personalization (Engraving) Settings:**
125
-
126
- The personalization feature is configured in `global.layout`:
127
-
128
- ```javascript
129
- customTheme: {
130
- global: {
131
- layout: {
132
- enablePersonalization: true, // Enable/disable engraving globally
133
- personalizationText: 'Make it yours', // Button text for adding personalization
134
- personalizationCardStyle: 'outlined' // Style: 'outlined' | 'filled'
135
- }
136
- }
137
- }
138
- ```
139
-
140
- - **`enablePersonalization`**: Master switch for engraving feature
141
- - **`personalizationText`**: Call-to-action text on product pages
142
- - **`personalizationCardStyle`**: Visual style in cart/checkout ('outlined' or 'filled')
143
- - **`poweredByMode`**: Visual mode for "Powered by" branding ('light' or 'dark')
144
-
145
- **Protected Setting:**
146
- ⚠️ **`showPoweredBy`** is a read-only setting controlled by LiquidCommerce. This paid feature cannot be customized through the `customTheme` configuration and is managed via your LiquidCommerce dashboard. However, you can customize `poweredByMode` to match your site's theme.
147
-
148
- ### `proxy`
149
-
150
- **Type:** `object`
151
- **Default:** `null`
152
-
153
- Proxy configuration for routing API requests through your server.
154
-
155
- ```javascript
156
- proxy: {
157
- baseUrl: 'https://yourdomain.com/api/liquidcommerce',
158
- headers: {
159
- 'X-Custom-Header': 'value'
160
- }
161
- }
162
- ```
163
-
164
- **Properties:**
165
-
166
- #### `proxy.baseUrl`
167
-
168
- **Type:** `string` (required)
169
-
170
- Base URL for your proxy endpoint.
171
-
172
- ```javascript
173
- baseUrl: 'https://yourdomain.com/api/liquidcommerce'
174
- ```
175
-
176
- The SDK automatically appends API paths: `/api/products`, `/api/cart`, etc.
177
-
178
- #### `proxy.headers`
179
-
180
- **Type:** `object` (optional)
181
-
182
- Custom headers to include in proxied requests.
183
-
184
- ```javascript
185
- headers: {
186
- 'X-Custom-Auth': 'your-token',
187
- 'X-Request-Id': 'unique-id'
188
- }
189
- ```
190
-
191
- See [`PROXY.md`](./PROXY.md) for implementation guide.
192
-
193
- ### `promoTicker`
194
-
195
- **Type:** `array`
196
- **Default:** `[]`
197
-
198
- Promotional ticker configuration for rotating messages.
199
-
200
- ```javascript
201
- promoTicker: [
202
- {
203
- promoCode: 'FREESHIP',
204
- text: ['Free Shipping Today!', 'Use code FREESHIP'],
205
- separator: '•',
206
- activeFrom: '2025-01-01T00:00:00Z',
207
- activeUntil: '2025-12-31T23:59:59Z'
208
- }
209
- ]
210
- ```
211
-
212
- **Properties:**
213
-
214
- #### `promoCode` (required)
215
-
216
- **Type:** `string`
217
-
218
- The promo code to apply when clicked.
219
-
220
- #### `text` (required)
221
-
222
- **Type:** `string[]`
223
-
224
- Array of messages to rotate through.
225
-
226
- ```javascript
227
- text: ['Message 1', 'Message 2', 'Message 3']
228
- ```
229
-
230
- #### `separator` (optional)
231
-
232
- **Type:** `string`
233
- **Default:** `'•'`
234
-
235
- Separator between rotating messages.
236
-
237
- ```javascript
238
- separator: '•' // Bullet
239
- separator: '|' // Pipe
240
- separator: '→' // Arrow
241
- ```
242
-
243
- #### `activeFrom` (optional)
244
-
245
- **Type:** `string` (ISO 8601)
246
-
247
- Start date/time for the promotion.
248
-
249
- ```javascript
250
- activeFrom: '2025-01-01T00:00:00Z'
251
- ```
252
-
253
- #### `activeUntil` (optional)
254
-
255
- **Type:** `string` (ISO 8601)
256
-
257
- End date/time for the promotion.
258
-
259
- ```javascript
260
- activeUntil: '2025-12-31T23:59:59Z'
261
- ```
262
-
263
- **Note:** Only active promotions are displayed.
264
-
265
- ## Auto-Initialization Configuration
266
-
267
- When using auto-initialization, configure via `data-` attributes on the script tag.
268
-
269
- ### Required Attributes
270
-
271
- ```html
272
- <script
273
- data-liquid-commerce-elements
274
- data-token="YOUR_API_KEY"
275
- src="https://assets-elements.liquidcommerce.us/all/elements.js"
276
- ></script>
277
- ```
278
-
279
- #### `data-liquid-commerce-elements`
280
-
281
- **Type:** flag (no value)
282
-
283
- Enables auto-initialization.
284
-
285
- #### `data-token`
286
-
287
- **Type:** `string` (required)
288
-
289
- Your LiquidCommerce API key.
290
-
291
- ### Optional Attributes
292
-
293
- #### `data-env`
294
-
295
- **Type:** `'production' | 'staging' | 'development' | 'local'`
296
- **Default:** `'production'`
297
-
298
- ```html
299
- data-env="production"
300
- ```
301
-
302
- #### `data-debug-mode`
303
-
304
- **Type:** `'console' | 'panel'`
305
- **Default:** Not set
306
-
307
- ```html
308
- data-debug-mode="console"
309
- ```
310
-
311
- #### `data-cart-button`
312
-
313
- **Type:** `string`
314
-
315
- Container ID, CSS selector, or position-prefixed selector for simple cart button (no badge).
316
-
317
- ```html
318
- <!-- Simple ID (with or without # prefix) -->
319
- data-cart-button="header-cart" <!-- Works with or without # -->
320
- data-cart-button="#header-cart" <!-- Also works with # prefix -->
321
-
322
- <!-- CSS Selector (from browser inspect tool) -->
323
- data-cart-button=".header .nav-links"
324
- data-cart-button="#main-navigation"
325
-
326
- <!-- Position-prefixed selectors -->
327
- data-cart-button="above:.header .logo" <!-- Place above the target -->
328
- data-cart-button="below:#main-navigation" <!-- Place below the target -->
329
- data-cart-button="below:main-navigation" <!-- Also works without # prefix -->
330
- data-cart-button="replace:.old-cart" <!-- Replace the target -->
331
- data-cart-button="inside:.header .nav" <!-- Place inside the target (default) -->
332
-
333
- <!-- Floating cart button (no badge) -->
334
- data-cart-button="" <!-- Empty value = floating button -->
335
- ```
336
-
337
- **Smart Fallback Behavior:**
338
- - If the target element is not found, automatically falls back to floating cart button
339
- - If attribute is present but empty (`data-cart-button=""`), creates floating cart button without badge
340
- - Element IDs are automatically prefixed with `#` if needed (e.g., `header-cart` becomes `#header-cart`)
341
-
342
- #### `data-cart-badge-button`
343
-
344
- **Type:** `string`
345
-
346
- Container ID, CSS selector, or position-prefixed selector for cart button with item count badge.
347
-
348
- ```html
349
- <!-- Simple ID (with or without # prefix) -->
350
- data-cart-badge-button="header-cart" <!-- Works with or without # -->
351
- data-cart-badge-button="#header-cart" <!-- Also works with # prefix -->
352
-
353
- <!-- CSS Selector (from browser inspect tool) -->
354
- data-cart-badge-button=".header .nav-links"
355
- data-cart-badge-button="#main-navigation"
356
-
357
- <!-- Position-prefixed selectors -->
358
- data-cart-badge-button="above:.header .logo" <!-- Place above the target -->
359
- data-cart-badge-button="below:#main-navigation" <!-- Place below the target -->
360
- data-cart-badge-button="replace:.old-cart" <!-- Replace the target -->
361
- data-cart-badge-button="inside:.header .nav" <!-- Place inside the target (default) -->
362
-
363
- <!-- Floating cart button with badge (default) -->
364
- data-cart-badge-button="" <!-- Empty value = floating button with badge -->
365
- ```
366
-
367
- **Smart Fallback Behavior:**
368
- - If the target element is not found, automatically falls back to floating cart button with badge
369
- - If attribute is present but empty (`data-cart-badge-button=""`), creates floating cart button with badge
370
- - Element IDs are automatically prefixed with `#` if needed
371
- - If neither `data-cart-button` nor `data-cart-badge-button` is provided, defaults to floating cart button with badge
372
-
373
- **Position Prefixes:**
374
- - `above:` - Place above the target element
375
- - `below:` - Place below the target element
376
- - `replace:` - Replace the target element
377
- - `inside:` - Place inside the target element (default)
378
-
379
- #### `data-cart-button-hidden`
380
-
381
- **Type:** flag (no value)
382
-
383
- Hide cart button completely. Use this when you want to manage cart display manually via `client.actions.cart.openCart()`.
384
-
385
- ```html
386
- data-cart-button-hidden
387
- ```
388
-
389
- **Important:** When this attribute is present, the SDK will skip all cart button setup, including floating buttons. This takes precedence over `data-cart-button` and `data-cart-badge-button` attributes.
390
-
391
- ### Cart Button Examples
392
-
393
- **Simple cart button (no badge):**
394
- ```html
395
- <script
396
- data-liquid-commerce-elements
397
- data-token="your-api-key"
398
- data-cart-button="header-cart"
399
- src="elements.js">
400
- </script>
401
- ```
402
-
403
- **Cart button with item count badge:**
404
- ```html
405
- <script
406
- data-liquid-commerce-elements
407
- data-token="your-api-key"
408
- data-cart-badge-button="header-cart"
409
- src="elements.js">
410
- </script>
411
- ```
412
-
413
- **Using position-prefixed selectors:**
414
- ```html
415
- <!-- Place inside the target element (default) -->
416
- <script
417
- data-liquid-commerce-elements
418
- data-token="your-api-key"
419
- data-cart-badge-button="inside:.header .nav-links"
420
- src="elements.js">
421
- </script>
422
-
423
- <!-- Place above the target element -->
424
- <script
425
- data-liquid-commerce-elements
426
- data-token="your-api-key"
427
- data-cart-button="above:.header .logo"
428
- src="elements.js">
429
- </script>
430
-
431
- <!-- Place below the target element -->
432
- <script
433
- data-liquid-commerce-elements
434
- data-token="your-api-key"
435
- data-cart-badge-button="below:#main-navigation"
436
- src="elements.js">
437
- </script>
438
-
439
- <!-- Replace the target element -->
440
- <script
441
- data-liquid-commerce-elements
442
- data-token="your-api-key"
443
- data-cart-button="replace:.old-cart-button"
444
- src="elements.js">
445
- </script>
446
- ```
447
-
448
- **No cart button:**
449
- ```html
450
- <script
451
- data-liquid-commerce-elements
452
- data-token="your-api-key"
453
- data-cart-button-hidden
454
- src="elements.js">
455
- </script>
456
- ```
457
-
458
- **Default behavior (floating cart button with badge):**
459
- ```html
460
- <script
461
- data-liquid-commerce-elements
462
- data-token="your-api-key"
463
- src="elements.js">
464
- </script>
465
- ```
466
-
467
- ### Getting CSS Selectors from Browser
468
-
469
- **Super Easy Method:**
470
- 1. **Right-click** on any element where you want the cart button
471
- 2. Select **"Inspect"** or **"Inspect Element"**
472
- 3. In developer tools, **right-click** on the highlighted element
473
- 4. Select **"Copy" → "Copy selector"**
474
- 5. Paste the selector into your `data-cart-button` or `data-cart-badge-button` attribute
475
-
476
- **Example:**
477
- ```html
478
- <!-- After copying selector from browser inspect tool -->
479
- <script
480
- data-liquid-commerce-elements
481
- data-token="your-api-key"
482
- data-cart-badge-button="body > div.container > header > nav > div.nav-links"
483
- src="elements.js">
484
- </script>
485
- ```
486
-
487
- ### Product Configuration
488
-
489
- #### Method 1: Direct Attributes
490
-
491
- ```html
492
- data-container-1="product-1"
493
- data-product-1="00619947000020"
494
- data-container-2="product-2"
495
- data-product-2="00832889005513"
496
- ```
497
-
498
- #### Method 2: JSON Configuration
499
-
500
- ```html
501
- <script data-liquid-commerce-elements-products type="application/json">
502
- [
503
- { "containerId": "product-1", "identifier": "00619947000020" },
504
- { "containerId": "product-2", "identifier": "00832889005513" }
505
- ]
506
- </script>
507
- ```
508
-
509
- #### Method 3: Annotated Elements
510
-
511
- ```html
512
- <div data-lce-product="00619947000020"></div>
513
- <div data-lce-product="00832889005513"></div>
514
- ```
515
-
516
- ### Product List Configuration
517
-
518
- ```html
519
- <div data-liquid-commerce-elements-products-list
520
- data-card="standard"
521
- data-rows="3"
522
- data-columns="4"
523
- data-card-fill
524
- data-filters="personalization,pre-order,delivery-options"
525
- data-product-url="/product/{upc}">
526
- </div>
527
- ```
528
-
529
- **Attributes:**
530
-
531
- ##### `data-liquid-commerce-elements-products-list`
532
-
533
- **Type:** flag (no value)
534
-
535
- Enables product list on this div element.
536
-
537
- ##### `data-card`
538
-
539
- **Type:** `'standard'`
540
- **Default:** `'standard'`
541
-
542
- Card variant style.
543
-
544
- ```html
545
- data-card="standard"
546
- ```
547
-
548
- ##### `data-rows`
549
-
550
- **Type:** `number`
551
- **Default:** `3`
552
-
553
- Number of rows to display per page.
554
-
555
- ```html
556
- data-rows="4"
557
- ```
558
-
559
- ##### `data-columns`
560
-
561
- **Type:** `number`
562
- **Default:** `4`
563
-
564
- Number of columns in the grid.
565
-
566
- ```html
567
- data-columns="4"
568
- ```
569
-
570
- ##### `data-card-fill`
571
-
572
- **Type:** flag (no value)
573
-
574
- Whether cards should fill the whole card with white background color to match the image background color.
575
-
576
- ```html
577
- data-card-fill
578
- ```
579
-
580
- ##### `data-filters`
581
-
582
- **Type:** `string` (comma-separated)
583
-
584
- Filter types to enable: `personalization`, `pre-order`, `delivery-options`.
585
-
586
- ```html
587
- data-filters="personalization,pre-order,delivery-options"
588
- ```
589
-
590
- **Available filters:**
591
- - `personalization` - Show filter for personalized/engravable products
592
- - `pre-order` - Show filter for pre-order products
593
- - `delivery-options` - Show filter for delivery type (all, shipping, onDemand)
594
-
595
- ##### `data-product-url`
596
-
597
- **Type:** `string`
598
-
599
- Product detail page URL template. Use `{upc}` or `{grouping}` placeholder.
600
-
601
- ```html
602
- data-product-url="/product/{upc}"
603
- data-product-url="/products/{grouping}"
604
- ```
605
-
606
- **Placeholders:**
607
- - `{upc}` - Replaced with product UPC
608
- - `{grouping}` - Replaced with Salsify grouping ID
609
-
610
- ### URL Parameter Configuration
611
-
612
- #### `data-product-param`
613
-
614
- **Type:** `string`
615
-
616
- URL parameter name for auto-adding products to cart.
617
-
618
- ```html
619
- data-product-param="lce_product"
620
- ```
621
-
622
- **Usage:** `?lce_product=00619947000020&lce_fulfillment=shipping`
623
-
624
- #### `data-product-fulfillment-type-param`
625
-
626
- **Type:** `string`
627
-
628
- URL parameter name for fulfillment type.
629
-
630
- ```html
631
- data-product-fulfillment-type-param="lce_fulfillment"
632
- ```
633
-
634
- **Values:** `shipping` or `onDemand`
635
-
636
- #### `data-promo-code-param`
637
-
638
- **Type:** `string`
639
-
640
- URL parameter name for auto-applying promo codes.
641
-
642
- ```html
643
- data-promo-code-param="lce_promo"
644
- ```
645
-
646
- **Usage:** `?lce_promo=SUMMER20`
647
-
648
- ### Promo Ticker Configuration
649
-
650
- #### `data-promo-code`
651
-
652
- **Type:** `string`
653
-
654
- Promo code to apply.
655
-
656
- ```html
657
- data-promo-code="FREESHIP"
658
- ```
659
-
660
- #### `data-promo-text`
661
-
662
- **Type:** `string` (pipe-separated)
663
-
664
- Messages to display.
665
-
666
- ```html
667
- data-promo-text="Free Shipping Today!|Use code FREESHIP"
668
- ```
669
-
670
- #### `data-promo-separator`
671
-
672
- **Type:** `string`
673
- **Default:** `'•'`
674
-
675
- ```html
676
- data-promo-separator="•"
677
- ```
678
-
679
- #### `data-promo-active-from`
680
-
681
- **Type:** `string` (ISO 8601)
682
-
683
- ```html
684
- data-promo-active-from="2025-01-01T00:00:00Z"
685
- ```
686
-
687
- #### `data-promo-active-until`
688
-
689
- **Type:** `string` (ISO 8601)
690
-
691
- ```html
692
- data-promo-active-until="2025-12-31T23:59:59Z"
693
- ```
694
-
695
- ## TypeScript Types
696
-
697
- ### `ILiquidCommerceElementsConfig`
698
-
699
- ```typescript
700
- interface ILiquidCommerceElementsConfig {
701
- env?: 'local' | 'development' | 'staging' | 'production';
702
- debugMode?: 'none' | 'console' | 'panel';
703
- isBuilder?: boolean;
704
- customTheme?: IClientCustomThemeConfig;
705
- proxy?: IElementsProxyConfig;
706
- promoTicker?: IPromoTicker[];
707
- }
708
- ```
709
-
710
- ### `IElementsProxyConfig`
711
-
712
- ```typescript
713
- interface IElementsProxyConfig {
714
- baseUrl: string;
715
- headers?: Record<string, string>;
716
- }
717
- ```
718
-
719
- ### `IPromoTicker`
720
-
721
- ```typescript
722
- interface IPromoTicker {
723
- promoCode: string;
724
- text: string[];
725
- separator: string;
726
- activeFrom: string; // ISO 8601 UTC format
727
- activeUntil: string; // ISO 8601 UTC format
728
- }
729
- ```
730
-
731
- ## Configuration Examples
732
-
733
- ### Production Setup
734
-
735
- ```javascript
736
- const client = await Elements('YOUR_PRODUCTION_API_KEY', {
737
- env: 'production',
738
- debugMode: 'none',
739
- proxy: {
740
- baseUrl: 'https://yourdomain.com/api/liquidcommerce'
741
- },
742
- customTheme: {
743
- global: {
744
- colors: {
745
- primary: '#007bff'
746
- }
747
- }
748
- }
749
- });
750
- ```
751
-
752
- ### Development Setup
753
-
754
- ```javascript
755
- const client = await Elements('YOUR_DEV_API_KEY', {
756
- env: 'development',
757
- debugMode: 'panel',
758
- isBuilder: true,
759
- customTheme: {
760
- global: {
761
- colors: {
762
- primary: '#ff6b6b'
763
- }
764
- }
765
- }
766
- });
767
- ```
768
-
769
- ### With Promo Ticker
770
-
771
- ```javascript
772
- const client = await Elements('YOUR_API_KEY', {
773
- env: 'production',
774
- promoTicker: [
775
- {
776
- promoCode: 'SUMMER20',
777
- text: ['20% Off Summer Sale!', 'Use code SUMMER20'],
778
- separator: '•',
779
- activeFrom: '2025-06-01T00:00:00Z',
780
- activeUntil: '2025-08-31T23:59:59Z'
781
- }
782
- ]
783
- });
784
- ```
785
-
786
- ## Configuration Validation
787
-
788
- The SDK validates configuration on initialization:
789
-
790
- ```javascript
791
- try {
792
- const client = await Elements('YOUR_API_KEY', {
793
- env: 'invalid' // ❌ Will throw error
794
- });
795
- } catch (error) {
796
- console.error('Invalid configuration:', error);
797
- }
798
- ```
799
-
800
- **Common validation errors:**
801
- - Invalid environment value
802
- - Missing API key
803
- - Invalid proxy baseUrl
804
- - Malformed promo ticker dates
805
-
806
- ## Environment Variables
807
-
808
- For framework integrations, use environment variables:
809
-
810
- ### React / Next.js
811
-
812
- ```javascript
813
- const client = await Elements(process.env.REACT_APP_LCE_API_KEY, {
814
- env: process.env.REACT_APP_LCE_ENV || 'production'
815
- });
816
- ```
817
-
818
- ### Vue
819
-
820
- ```javascript
821
- const client = await Elements(process.env.VUE_APP_LCE_API_KEY, {
822
- env: process.env.VUE_APP_LCE_ENV || 'production'
823
- });
824
- ```
825
-
826
- ### Node.js / Server-Side
827
-
828
- ```javascript
829
- const client = await Elements(process.env.LCE_API_KEY, {
830
- env: process.env.NODE_ENV === 'production' ? 'production' : 'development'
831
- });
832
- ```
833
-
834
- ## Configuration Best Practices
835
-
836
- 1. **Use environment variables** for API keys (never hardcode)
837
- 2. **Enable debug mode only in development** (security risk in production)
838
- 3. **Pin to specific version** in production for stability
839
- 4. **Configure proxy** if targeting ad blocker-heavy audiences
840
- 5. **Use minimal theme overrides** for optimal performance
841
- 6. **Set GTM container ID** for analytics tracking
842
- 7. **Test configuration** in staging before production
843
- 8. **Validate promo dates** to avoid expired promotions
844
- 9. **Use builder mode** only in development (performance overhead)
845
- 10. **Monitor proxy** health if using custom proxy
846
-
847
- ## Related Documentation
848
-
849
- - [Theming Guide](./THEMING.md) - Complete theme configuration reference
850
- - [Proxy Setup](./PROXY.md) - Proxy implementation guide
851
- - [Actions Reference](./ACTIONS.md) - Programmatic control API
852
- - [Events Reference](./EVENTS.md) - Event system and tracking
853
-