@liquidcommerce/elements-sdk 2.6.7 → 2.7.0
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.
- package/README.md +302 -71
- package/dist/index.checkout.esm.js +16034 -0
- package/dist/index.esm.js +14201 -12166
- package/dist/types/auto-initialize/checkout.d.ts +2 -0
- package/dist/types/auto-initialize/shared-utils.d.ts +22 -0
- package/dist/types/{elements-base-client.d.ts → clients/base.d.ts} +11 -1
- package/dist/types/clients/checkout.d.ts +13 -0
- package/dist/types/constants/core.constant.d.ts +9 -3
- package/dist/types/core/api/api-client.service.d.ts +0 -2
- package/dist/types/core/client/actions/base-action.service.d.ts +15 -0
- package/dist/types/core/client/actions/client-address-action.service.d.ts +18 -0
- package/dist/types/core/client/actions/client-cart-action.service.d.ts +37 -0
- package/dist/types/core/client/actions/client-checkout-action.service.d.ts +50 -0
- package/dist/types/core/client/actions/client-product-action.service.d.ts +12 -0
- package/dist/types/core/client/client-action.service.d.ts +6 -73
- package/dist/types/core/client/client-config.service.d.ts +3 -4
- package/dist/types/core/store/interfaces/core.interface.d.ts +14 -1
- package/dist/types/core/store/interfaces/metadata.interface.d.ts +11 -0
- package/dist/types/core/store/interfaces/product-list.interface.d.ts +45 -0
- package/dist/types/core/store/interfaces/product.interface.d.ts +1 -0
- package/dist/types/core/store/store.constant.d.ts +4 -0
- package/dist/types/enums/core.enum.d.ts +3 -1
- package/dist/types/enums/index.d.ts +0 -1
- package/dist/types/index.checkout.d.ts +7 -0
- package/dist/types/index.checkout.umd.d.ts +4 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/interfaces/api/checkout.interface.d.ts +2 -1
- package/dist/types/interfaces/api/product-list.interface.d.ts +13 -5
- package/dist/types/interfaces/configs/checkout.interface.d.ts +1 -0
- package/dist/types/interfaces/configs/global.interface.d.ts +4 -2
- package/dist/types/interfaces/configs/index.d.ts +1 -0
- package/dist/types/interfaces/configs/product-list.interface.d.ts +28 -0
- package/dist/types/interfaces/core.interface.d.ts +28 -6
- package/dist/types/modules/address/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/checkout/checkout.commands.d.ts +6 -2
- package/dist/types/modules/checkout/checkout.component.d.ts +2 -0
- package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +2 -0
- package/dist/types/modules/checkout/components/checkout-header.component.d.ts +1 -0
- package/dist/types/modules/checkout/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/product/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/product-list/components/card-components/index.d.ts +4 -0
- package/dist/types/modules/product-list/components/card-components/product-button.d.ts +11 -0
- package/dist/types/modules/product-list/components/card-components/product-fulfillments.d.ts +10 -0
- package/dist/types/modules/product-list/components/card-components/product-quantity-selector.d.ts +10 -0
- package/dist/types/modules/product-list/components/card-components/product-sizes-list.d.ts +9 -0
- package/dist/types/modules/product-list/components/filter-components/index.d.ts +7 -0
- package/dist/types/modules/product-list/components/filter-components/product-list-apply-filter-button.d.ts +1 -0
- package/dist/types/modules/product-list/components/filter-components/product-list-chip.d.ts +5 -0
- package/dist/types/modules/product-list/components/filter-components/product-list-filters-chips.d.ts +13 -0
- package/dist/types/modules/product-list/components/filter-components/product-list-fulfillment-filter.d.ts +14 -0
- 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
- package/dist/types/modules/product-list/components/filter-components/product-list-toggle-filters.d.ts +13 -0
- package/dist/types/modules/product-list/components/index.d.ts +6 -3
- package/dist/types/modules/product-list/components/product-list-card-loading.component.d.ts +2 -1
- package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +6 -0
- package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +58 -37
- package/dist/types/modules/product-list/components/product-list-retailers.component.d.ts +18 -0
- package/dist/types/modules/product-list/components/product-list-search.component.d.ts +22 -0
- package/dist/types/modules/product-list/product-list-card.component.d.ts +35 -0
- package/dist/types/modules/product-list/product-list.commands.d.ts +53 -3
- package/dist/types/modules/product-list/product-list.component.d.ts +16 -43
- package/dist/types/{enums/cloud.enum.d.ts → modules/product-list/product-list.constants.d.ts} +20 -1
- package/dist/types/modules/product-list/product-list.interface.d.ts +32 -24
- package/dist/types/modules/product-list/styles/product-list-card.style.d.ts +1 -0
- package/dist/types/modules/product-list/styles/product-list-filters.style.d.ts +1 -0
- package/dist/types/modules/product-list/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/theme-provider/constants/component-groupings.d.ts +1 -0
- package/dist/types/modules/theme-provider/constants/css-variable-mappings.d.ts +1 -1
- package/dist/types/modules/theme-provider/services/style-registry.service.d.ts +16 -0
- package/dist/types/modules/theme-provider/services/stylesheet-generator.service.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/theme-provider/theme-provider.service.d.ts +2 -1
- package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +4 -1
- package/dist/types/modules/ui-components/input/index.d.ts +0 -1
- package/dist/types/modules/ui-components/input/input.component.d.ts +8 -1
- package/dist/types/modules/ui-components/modal/modal.component.d.ts +23 -0
- package/dist/types/modules/ui-components/styles/modal.style.d.ts +1 -0
- package/dist/types/modules/ui-components/ui.commands.d.ts +3 -1
- package/dist/types/static/icon/check.icon.d.ts +2 -0
- package/dist/types/static/icon/index.d.ts +1 -0
- package/docs/ACTIONS.md +1 -0
- package/docs/CONFIGURATION.md +178 -34
- package/docs/DOCUMENTATION_INDEX.md +12 -4
- package/docs/THEMING.md +107 -18
- package/package.json +19 -12
- package/dist/types/modules/product-list/components/product-list-card.component.d.ts +0 -37
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/index.d.ts +0 -6
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-apply-filter-button.component.d.ts +0 -1
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-delivery-options-filter.components.d.ts +0 -16
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-search.component.d.ts +0 -16
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-toggle-filters.components.d.ts +0 -18
- package/dist/types/modules/theme-provider/styles/address/index.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/cart/index.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/checkout/index.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/product/index.d.ts +0 -3
- package/dist/types/modules/theme-provider/styles/product-list/index.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/ui/index.d.ts +0 -3
- package/dist/types/modules/ui-components/input/birthdate-input.component.d.ts +0 -53
- package/umd/elements.js +0 -1
- /package/dist/types/{auto-initialize.d.ts → auto-initialize/main.d.ts} +0 -0
- /package/dist/types/{elements-builder-client.d.ts → clients/builder.d.ts} +0 -0
- /package/dist/types/{elements-client-helper.d.ts → clients/helpers.d.ts} +0 -0
- /package/dist/types/{elements-client.d.ts → clients/main.d.ts} +0 -0
- /package/dist/types/modules/{theme-provider/styles/address → address/styles}/address.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/cart → cart/styles}/cart.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/checkout → checkout/styles}/checkout.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/product → product/styles}/image-carousel.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/product → product/styles}/product.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/product → product/styles}/retailers.style.d.ts +0 -0
- /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
- /package/dist/types/modules/{theme-provider/styles/product-list → product-list/styles}/product-list.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/drawer.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/loading.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/promo-code-ticker.style.d.ts +0 -0
package/README.md
CHANGED
|
@@ -9,12 +9,11 @@ Elements SDK
|
|
|
9
9
|
|
|
10
10
|
[](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
|
|
11
11
|
[](https://www.typescriptlang.org/)
|
|
12
|
-
[](https://pnpm.io/)
|
|
12
|
+
[](https://pnpm.io/)
|
|
14
13
|
[](https://rollupjs.org/)
|
|
14
|
+

|
|
15
15
|
|
|
16
16
|
[](LICENSE)
|
|
17
|
-
[](./umd)
|
|
18
17
|
[](./package.json)
|
|
19
18
|
[](./docs/BROWSER_SUPPORT.md)
|
|
20
19
|
|
|
@@ -69,8 +68,9 @@ The LiquidCommerce Elements SDK is a **production-ready JavaScript library** tha
|
|
|
69
68
|
|
|
70
69
|
**🛍️ Complete E-commerce**
|
|
71
70
|
- Product display components
|
|
71
|
+
- Product list with filters and search
|
|
72
72
|
- Shopping cart with real-time updates
|
|
73
|
-
- Full checkout flow
|
|
73
|
+
- Full checkout flow (drawer or hosted page)
|
|
74
74
|
- Address management
|
|
75
75
|
|
|
76
76
|
</td>
|
|
@@ -200,10 +200,9 @@ Add a product list to any page with a data attribute:
|
|
|
200
200
|
|
|
201
201
|
```html
|
|
202
202
|
<div data-liquid-commerce-elements-products-list
|
|
203
|
-
data-card="standard"
|
|
204
203
|
data-rows="3"
|
|
205
204
|
data-columns="4"
|
|
206
|
-
data-filters="
|
|
205
|
+
data-filters="engraving,presale,fulfillment,price,brands"
|
|
207
206
|
data-product-url="/product/{upc}">
|
|
208
207
|
</div>
|
|
209
208
|
|
|
@@ -217,13 +216,13 @@ Add a product list to any page with a data attribute:
|
|
|
217
216
|
|
|
218
217
|
**Attributes:**
|
|
219
218
|
- `data-liquid-commerce-elements-products-list` - Enables product list on this div
|
|
220
|
-
- `data-
|
|
221
|
-
- `data-
|
|
222
|
-
- `data-
|
|
223
|
-
- `data-card-fill` - Makes cards fill available space (optional flag)
|
|
224
|
-
- `data-filters` - Comma-separated filters: `personalization`, `pre-order`, `delivery-options`
|
|
219
|
+
- `data-rows` - Number of rows per page (1-10, default: `3`)
|
|
220
|
+
- `data-columns` - Number of columns (1-4, default: `4`)
|
|
221
|
+
- `data-filters` - Comma-separated filters (see available filters below)
|
|
225
222
|
- `data-product-url` - Product URL template with `{upc}` or `{grouping}` placeholder
|
|
226
223
|
|
|
224
|
+
**Available filters:** `engraving`, `presale`, `fulfillment`, `price`, `brands`, `categories`, `flavor`, `region`, `variety`, `vintage`, `country`, `appellation`, `materials`, `sizes`
|
|
225
|
+
|
|
227
226
|
**Use case:** Category pages, catalog pages, search results, filtered product browsing
|
|
228
227
|
|
|
229
228
|
### Customizing the Cart Button
|
|
@@ -293,7 +292,53 @@ If no cart button attribute is provided, or if the target element is not found,
|
|
|
293
292
|
></script>
|
|
294
293
|
```
|
|
295
294
|
|
|
296
|
-
#### Option 3:
|
|
295
|
+
#### Option 3: Separate Mobile Cart Button
|
|
296
|
+
|
|
297
|
+
Configure different cart button placements for desktop and mobile:
|
|
298
|
+
|
|
299
|
+
```html
|
|
300
|
+
<script
|
|
301
|
+
data-liquid-commerce-elements
|
|
302
|
+
data-token="YOUR_API_KEY"
|
|
303
|
+
data-env="production"
|
|
304
|
+
data-cart-badge-button="above:.desktop-nav"
|
|
305
|
+
data-cart-mobile-badge-button="below:.mobile-header"
|
|
306
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
307
|
+
></script>
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**Mobile button attributes:**
|
|
311
|
+
- `data-cart-mobile-button` - Mobile cart button (no badge)
|
|
312
|
+
- `data-cart-mobile-badge-button` - Mobile cart button with item count badge
|
|
313
|
+
|
|
314
|
+
These support the same position prefixes as the desktop attributes (`above:`, `below:`, `replace:`, `inside:`).
|
|
315
|
+
|
|
316
|
+
**Use case:** Different navigation layouts for desktop and mobile
|
|
317
|
+
|
|
318
|
+
#### Option 4: Custom Cart Toggle Button
|
|
319
|
+
|
|
320
|
+
Use your own button element to toggle the cart:
|
|
321
|
+
|
|
322
|
+
```html
|
|
323
|
+
<button data-lce-cart-toggle-button>My Cart</button>
|
|
324
|
+
<span data-lce-cart-items-count>0</span>
|
|
325
|
+
|
|
326
|
+
<script
|
|
327
|
+
data-liquid-commerce-elements
|
|
328
|
+
data-token="YOUR_API_KEY"
|
|
329
|
+
data-env="production"
|
|
330
|
+
data-cart-button-hidden
|
|
331
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
332
|
+
></script>
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
**Attributes:**
|
|
336
|
+
- `data-lce-cart-toggle-button` - Any element with this attribute becomes a cart toggle
|
|
337
|
+
- `data-lce-cart-items-count` - Auto-updates with cart item count. Use value `"keep-zero"` to show count even when cart is empty
|
|
338
|
+
|
|
339
|
+
**Use case:** Fully custom cart button with your own styling
|
|
340
|
+
|
|
341
|
+
#### Option 5: No Cart Button (Manual Control)
|
|
297
342
|
|
|
298
343
|
Hide the cart button completely when you want to manage cart access manually:
|
|
299
344
|
|
|
@@ -400,65 +445,151 @@ Here's every available data attribute:
|
|
|
400
445
|
```html
|
|
401
446
|
<script
|
|
402
447
|
data-liquid-commerce-elements
|
|
403
|
-
|
|
448
|
+
|
|
404
449
|
<!-- Required -->
|
|
405
450
|
data-token="YOUR_API_KEY"
|
|
406
|
-
|
|
451
|
+
|
|
407
452
|
<!-- Environment -->
|
|
408
453
|
data-env="production|staging|development|local"
|
|
409
|
-
|
|
410
|
-
<!-- Cart Button -->
|
|
454
|
+
|
|
455
|
+
<!-- Cart Button (Desktop) -->
|
|
411
456
|
data-cart-button="container-id" <!-- Simple cart button (no badge) -->
|
|
412
457
|
data-cart-badge-button="container-id" <!-- Cart button with badge -->
|
|
413
458
|
data-cart-button-hidden <!-- Hide cart button completely -->
|
|
414
|
-
|
|
459
|
+
|
|
460
|
+
<!-- Cart Button (Mobile) -->
|
|
461
|
+
data-cart-mobile-button="container-id" <!-- Mobile cart button (no badge) -->
|
|
462
|
+
data-cart-mobile-badge-button="container-id" <!-- Mobile cart button with badge -->
|
|
463
|
+
|
|
415
464
|
<!-- Cart Button with Position Prefixes -->
|
|
416
465
|
data-cart-button="above:.logo" <!-- Place above target -->
|
|
417
466
|
data-cart-badge-button="below:#header" <!-- Place below target -->
|
|
418
467
|
data-cart-button="inside:.nav" <!-- Place inside target (default) -->
|
|
419
468
|
data-cart-badge-button="replace:.old-cart" <!-- Replace target -->
|
|
420
|
-
|
|
469
|
+
|
|
421
470
|
<!-- Cart Button Floating (empty values) -->
|
|
422
471
|
data-cart-button="" <!-- Floating button without badge -->
|
|
423
472
|
data-cart-badge-button="" <!-- Floating button with badge -->
|
|
424
|
-
|
|
473
|
+
|
|
425
474
|
<!-- Products (Method 1: Direct) -->
|
|
426
475
|
data-container-1="div-id"
|
|
427
476
|
data-product-1="identifier"
|
|
428
477
|
data-container-2="div-id"
|
|
429
478
|
data-product-2="identifier"
|
|
430
|
-
|
|
431
|
-
<!-- Product List -->
|
|
432
|
-
<div data-liquid-commerce-elements-products-list
|
|
433
|
-
data-card="standard"
|
|
434
|
-
data-rows="3"
|
|
435
|
-
data-columns="4"
|
|
436
|
-
data-card-fill
|
|
437
|
-
data-filters="personalization,pre-order,delivery-options"
|
|
438
|
-
data-product-url="/product/{upc}">
|
|
439
|
-
</div>
|
|
440
|
-
|
|
479
|
+
|
|
441
480
|
<!-- URL Parameters -->
|
|
442
481
|
data-product-param="lce_product"
|
|
443
482
|
data-product-fulfillment-type-param="lce_fulfillment"
|
|
444
483
|
data-promo-code-param="lce_promo"
|
|
445
|
-
|
|
484
|
+
|
|
446
485
|
<!-- Promo Ticker -->
|
|
447
486
|
data-promo-code="CODE"
|
|
448
487
|
data-promo-text="Message 1|Message 2"
|
|
449
488
|
data-promo-separator="•"
|
|
450
489
|
data-promo-active-from="2025-01-01T00:00:00Z"
|
|
451
490
|
data-promo-active-until="2025-12-31T23:59:59Z"
|
|
452
|
-
|
|
491
|
+
|
|
492
|
+
<!-- Checkout Page (Hosted Checkout) -->
|
|
493
|
+
data-checkout-url="https://yoursite.com/checkout?id={id}"
|
|
494
|
+
|
|
453
495
|
<!-- Debugging (dev only) -->
|
|
454
496
|
data-debug-mode="console|panel"
|
|
455
|
-
|
|
497
|
+
|
|
456
498
|
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
457
499
|
></script>
|
|
500
|
+
|
|
501
|
+
<!-- Product List (on separate div element) -->
|
|
502
|
+
<div data-liquid-commerce-elements-products-list
|
|
503
|
+
data-rows="3"
|
|
504
|
+
data-columns="4"
|
|
505
|
+
data-filters="engraving,presale,fulfillment,price,brands"
|
|
506
|
+
data-product-url="/product/{upc}">
|
|
507
|
+
</div>
|
|
508
|
+
|
|
509
|
+
<!-- Custom Cart Toggle Button (on any button/element) -->
|
|
510
|
+
<button data-lce-cart-toggle-button>My Cart</button>
|
|
511
|
+
|
|
512
|
+
<!-- Custom Cart Items Count Display (on any element) -->
|
|
513
|
+
<span data-lce-cart-items-count>0</span>
|
|
514
|
+
<!-- Use "keep-zero" value to always show count, even when 0 -->
|
|
515
|
+
<span data-lce-cart-items-count="keep-zero">0</span>
|
|
458
516
|
```
|
|
459
517
|
|
|
460
518
|
**📖 For complete auto-init options:** See [`docs/CONFIGURATION.md`](docs/CONFIGURATION.md) for all data attributes and configuration details.
|
|
461
519
|
|
|
520
|
+
### Hosted Checkout (External Checkout Page)
|
|
521
|
+
|
|
522
|
+
Instead of using the default checkout drawer, you can redirect customers to a dedicated checkout page on your site. This is useful when you want a full-page checkout experience.
|
|
523
|
+
|
|
524
|
+
#### Auto-Init Setup
|
|
525
|
+
|
|
526
|
+
```html
|
|
527
|
+
<!-- On your product/cart pages -->
|
|
528
|
+
<script
|
|
529
|
+
data-liquid-commerce-elements
|
|
530
|
+
data-token="YOUR_API_KEY"
|
|
531
|
+
data-env="production"
|
|
532
|
+
data-checkout-url="https://yoursite.com/checkout?id={id}"
|
|
533
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
534
|
+
></script>
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
When `data-checkout-url` is set, the "Go to Checkout" button in the cart will redirect to that URL instead of opening the checkout drawer. The `{id}` placeholder is replaced with the checkout token generated by the SDK.
|
|
538
|
+
|
|
539
|
+
#### Checkout Page Setup
|
|
540
|
+
|
|
541
|
+
On your dedicated checkout page, use the **checkout-only build** for a smaller bundle:
|
|
542
|
+
|
|
543
|
+
```html
|
|
544
|
+
<div id="checkout-container"></div>
|
|
545
|
+
|
|
546
|
+
<script
|
|
547
|
+
data-liquid-commerce-checkout
|
|
548
|
+
data-token="YOUR_API_KEY"
|
|
549
|
+
data-env="production"
|
|
550
|
+
src="https://assets-elements.liquidcommerce.us/checkout/elements.js"
|
|
551
|
+
></script>
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
Or initialize programmatically:
|
|
555
|
+
|
|
556
|
+
```js
|
|
557
|
+
import { ElementsCheckout } from '@liquidcommerce/elements-sdk/checkout';
|
|
558
|
+
|
|
559
|
+
const client = await ElementsCheckout('YOUR_API_KEY', {
|
|
560
|
+
env: 'production'
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
// Inject checkout, optionally passing the checkout token from the URL
|
|
564
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
565
|
+
const component = await client.injectCheckout({
|
|
566
|
+
containerId: 'checkout-container',
|
|
567
|
+
checkoutId: urlParams.get('id'), // The checkout token from the URL
|
|
568
|
+
hideHeader: true
|
|
569
|
+
});
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
**Checkout-only build features:**
|
|
573
|
+
- Smaller bundle size (tree-shaken, no product/cart/PLP components)
|
|
574
|
+
- All checkout actions available (`actions.checkout.*`)
|
|
575
|
+
- Same theming and event system as the full SDK
|
|
576
|
+
- Auto-initialization via `data-liquid-commerce-checkout` attribute
|
|
577
|
+
|
|
578
|
+
**Use case:** Dedicated checkout pages, custom checkout flows, multi-page checkout
|
|
579
|
+
|
|
580
|
+
#### Programmatic Setup (Full SDK)
|
|
581
|
+
|
|
582
|
+
You can also configure hosted checkout programmatically with the full SDK:
|
|
583
|
+
|
|
584
|
+
```js
|
|
585
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
586
|
+
env: 'production',
|
|
587
|
+
checkout: {
|
|
588
|
+
pageUrl: 'https://yoursite.com/checkout?id={id}'
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
```
|
|
592
|
+
|
|
462
593
|
---
|
|
463
594
|
|
|
464
595
|
## 🔧 Advanced Usage
|
|
@@ -548,7 +679,10 @@ const client = await Elements('YOUR_API_KEY', {
|
|
|
548
679
|
debugMode: 'none', // Debug mode
|
|
549
680
|
customTheme: { }, // Theme overrides
|
|
550
681
|
proxy: { }, // Proxy configuration
|
|
551
|
-
promoTicker: [ ]
|
|
682
|
+
promoTicker: [ ], // Promotional messages
|
|
683
|
+
checkout: { // Hosted checkout configuration
|
|
684
|
+
pageUrl: 'https://yoursite.com/checkout?id={id}'
|
|
685
|
+
}
|
|
552
686
|
});
|
|
553
687
|
```
|
|
554
688
|
|
|
@@ -697,7 +831,11 @@ const component = await client.injectCartElement('cart-container');
|
|
|
697
831
|
#### Checkout
|
|
698
832
|
|
|
699
833
|
```js
|
|
700
|
-
const component = await client.injectCheckoutElement(
|
|
834
|
+
const component = await client.injectCheckoutElement({
|
|
835
|
+
containerId: 'checkout-container',
|
|
836
|
+
checkoutId: 'checkout-token', // Optional: load specific checkout by checkout token
|
|
837
|
+
hideHeader: false // Optional: hide checkout header in standalone mode
|
|
838
|
+
});
|
|
701
839
|
|
|
702
840
|
// Returns: IInjectedComponent | null - Component wrapper or null if failed
|
|
703
841
|
// component.rerender() - Rerender the component
|
|
@@ -705,7 +843,12 @@ const component = await client.injectCheckoutElement('checkout-container');
|
|
|
705
843
|
// component.getType() - Get component type
|
|
706
844
|
```
|
|
707
845
|
|
|
708
|
-
**
|
|
846
|
+
**Parameters:**
|
|
847
|
+
- `containerId` (required) - Where to inject the checkout
|
|
848
|
+
- `checkoutId` (optional) - Checkout token to load a specific checkout session
|
|
849
|
+
- `hideHeader` (optional) - Hide the checkout header when used in standalone/hosted mode
|
|
850
|
+
|
|
851
|
+
**Use case:** Dedicated checkout page, hosted checkout
|
|
709
852
|
|
|
710
853
|
#### Address
|
|
711
854
|
|
|
@@ -725,31 +868,40 @@ const component = await client.injectAddressElement('address-container');
|
|
|
725
868
|
```js
|
|
726
869
|
await client.injectProductList({
|
|
727
870
|
containerId: 'product-list-container',
|
|
728
|
-
rows: 3,
|
|
729
|
-
columns: 4,
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
'
|
|
734
|
-
'
|
|
735
|
-
'
|
|
871
|
+
rows: 3, // Number of rows per page (1-10)
|
|
872
|
+
columns: 4, // Number of columns (1-4)
|
|
873
|
+
filters: [ // Optional filters
|
|
874
|
+
'engraving', // Engravable/personalizable products
|
|
875
|
+
'presale', // Pre-order products
|
|
876
|
+
'fulfillment', // Delivery type filter (shipping, onDemand)
|
|
877
|
+
'price', // Price range filter
|
|
878
|
+
'brands', // Brand filter
|
|
879
|
+
'categories', // Category filter
|
|
880
|
+
'flavor', // Flavor filter
|
|
881
|
+
'region', // Region filter
|
|
882
|
+
'variety', // Variety filter
|
|
883
|
+
'vintage', // Vintage filter
|
|
884
|
+
'country', // Country filter
|
|
885
|
+
'appellation', // Appellation filter
|
|
886
|
+
'materials', // Materials filter
|
|
887
|
+
'sizes' // Size filter
|
|
736
888
|
],
|
|
737
|
-
productUrl: '/product/{upc}'
|
|
889
|
+
productUrl: '/product/{upc}' // Optional: Product detail page URL template
|
|
738
890
|
});
|
|
739
891
|
```
|
|
740
892
|
|
|
741
893
|
**Parameters:**
|
|
742
894
|
- `containerId` - Where to inject the product list
|
|
743
|
-
- `rows` - Number of rows to display per page (default: `3`)
|
|
744
|
-
- `columns` - Number of columns in the grid (default: `4`)
|
|
745
|
-
- `
|
|
746
|
-
- `fillCard` - Whether cards should fill available space (default: `false`)
|
|
747
|
-
- `filters` - Array of filter types to enable: `'personalization'`, `'pre-order'`, `'delivery-options'`
|
|
895
|
+
- `rows` - Number of rows to display per page (1-10, default: `3`)
|
|
896
|
+
- `columns` - Number of columns in the grid (1-4, default: `4`)
|
|
897
|
+
- `filters` - Array of filter types to enable (see available filters below)
|
|
748
898
|
- `productUrl` - Optional URL template for product links. Use `{upc}` or `{grouping}` placeholder
|
|
749
899
|
|
|
900
|
+
**Available filters:** `engraving`, `presale`, `fulfillment`, `price`, `brands`, `categories`, `flavor`, `region`, `variety`, `vintage`, `country`, `appellation`, `materials`, `sizes`
|
|
901
|
+
|
|
750
902
|
**Features:**
|
|
751
903
|
- ✅ Infinite scroll pagination
|
|
752
|
-
- ✅
|
|
904
|
+
- ✅ Rich filtering (14 filter types)
|
|
753
905
|
- ✅ Address-aware (reloads when address changes)
|
|
754
906
|
- ✅ Loading states and error handling
|
|
755
907
|
- ✅ Automatic GTM tracking (`view_item_list`, `select_item`)
|
|
@@ -760,6 +912,35 @@ await client.injectProductList({
|
|
|
760
912
|
|
|
761
913
|
**Note:** The product list automatically reloads when the address changes to show availability for the new location.
|
|
762
914
|
|
|
915
|
+
#### Product List Search
|
|
916
|
+
|
|
917
|
+
```js
|
|
918
|
+
await client.injectProductListSearch({
|
|
919
|
+
containerId: 'search-container'
|
|
920
|
+
});
|
|
921
|
+
```
|
|
922
|
+
|
|
923
|
+
Injects a search input component that works with the product list to filter products by keyword.
|
|
924
|
+
|
|
925
|
+
**Use case:** Search bars on catalog/category pages
|
|
926
|
+
|
|
927
|
+
#### Product List Filters
|
|
928
|
+
|
|
929
|
+
```js
|
|
930
|
+
await client.injectProductListFilters({
|
|
931
|
+
containerId: 'filters-container',
|
|
932
|
+
filters: ['price', 'brands', 'categories', 'variety']
|
|
933
|
+
});
|
|
934
|
+
```
|
|
935
|
+
|
|
936
|
+
Injects a standalone filter panel component that works with the product list. Use this when you want the filters in a separate container from the product grid (e.g., a sidebar).
|
|
937
|
+
|
|
938
|
+
**Parameters:**
|
|
939
|
+
- `containerId` - Where to inject the filter panel
|
|
940
|
+
- `filters` - Array of filter types to display
|
|
941
|
+
|
|
942
|
+
**Use case:** Sidebar filter panels on category pages
|
|
943
|
+
|
|
763
944
|
#### Access All Injected Components
|
|
764
945
|
|
|
765
946
|
```js
|
|
@@ -878,7 +1059,11 @@ client.builder.updateAddressComponent(addressTheme);
|
|
|
878
1059
|
// Builder injection methods (same as regular methods)
|
|
879
1060
|
const components = await client.builder.injectProductElement(params);
|
|
880
1061
|
const component = await client.builder.injectCartElement(containerId);
|
|
881
|
-
const checkoutComponent = await client.builder.injectCheckoutElement(
|
|
1062
|
+
const checkoutComponent = await client.builder.injectCheckoutElement({
|
|
1063
|
+
containerId,
|
|
1064
|
+
checkoutId, // Optional
|
|
1065
|
+
hideHeader // Optional
|
|
1066
|
+
});
|
|
882
1067
|
const addressComponent = await client.builder.injectAddressElement(containerId);
|
|
883
1068
|
|
|
884
1069
|
// All return IInjectedComponent wrapper objects with rerender(), getElement(), getType() methods
|
|
@@ -1043,6 +1228,7 @@ await actions.cart.resetCart();
|
|
|
1043
1228
|
actions.checkout.openCheckout();
|
|
1044
1229
|
actions.checkout.closeCheckout();
|
|
1045
1230
|
actions.checkout.toggleCheckout();
|
|
1231
|
+
actions.checkout.exitCheckout(); // Exit checkout (return to cart)
|
|
1046
1232
|
|
|
1047
1233
|
// Pre-fill customer information
|
|
1048
1234
|
actions.checkout.updateCustomerInfo({
|
|
@@ -1624,10 +1810,27 @@ Add a product list to any page with data attributes:
|
|
|
1624
1810
|
|
|
1625
1811
|
```html
|
|
1626
1812
|
<div data-liquid-commerce-elements-products-list
|
|
1627
|
-
data-card="standard"
|
|
1628
1813
|
data-rows="3"
|
|
1629
1814
|
data-columns="4"
|
|
1630
|
-
data-filters="
|
|
1815
|
+
data-filters="engraving,presale,fulfillment,price,brands"
|
|
1816
|
+
data-product-url="/product/{upc}">
|
|
1817
|
+
</div>
|
|
1818
|
+
```
|
|
1819
|
+
|
|
1820
|
+
You can also add separate search and filter containers:
|
|
1821
|
+
|
|
1822
|
+
```html
|
|
1823
|
+
<!-- Search bar -->
|
|
1824
|
+
<div data-search-container></div>
|
|
1825
|
+
|
|
1826
|
+
<!-- Sidebar filters -->
|
|
1827
|
+
<div data-filters-container></div>
|
|
1828
|
+
|
|
1829
|
+
<!-- Product grid -->
|
|
1830
|
+
<div data-liquid-commerce-elements-products-list
|
|
1831
|
+
data-rows="4"
|
|
1832
|
+
data-columns="4"
|
|
1833
|
+
data-filters="price,brands,categories,variety"
|
|
1631
1834
|
data-product-url="/product/{upc}">
|
|
1632
1835
|
</div>
|
|
1633
1836
|
```
|
|
@@ -1639,23 +1842,42 @@ await client.injectProductList({
|
|
|
1639
1842
|
containerId: 'product-list-container',
|
|
1640
1843
|
rows: 3,
|
|
1641
1844
|
columns: 4,
|
|
1642
|
-
|
|
1643
|
-
fillCard: false,
|
|
1644
|
-
filters: ['personalization', 'pre-order', 'delivery-options'],
|
|
1845
|
+
filters: ['engraving', 'presale', 'fulfillment', 'price', 'brands'],
|
|
1645
1846
|
productUrl: '/product/{upc}'
|
|
1646
1847
|
});
|
|
1848
|
+
|
|
1849
|
+
// Optional: inject search and filters in separate containers
|
|
1850
|
+
await client.injectProductListSearch({
|
|
1851
|
+
containerId: 'search-container'
|
|
1852
|
+
});
|
|
1853
|
+
|
|
1854
|
+
await client.injectProductListFilters({
|
|
1855
|
+
containerId: 'filters-sidebar',
|
|
1856
|
+
filters: ['price', 'brands', 'categories', 'variety']
|
|
1857
|
+
});
|
|
1647
1858
|
```
|
|
1648
1859
|
|
|
1649
1860
|
#### Features
|
|
1650
1861
|
|
|
1651
|
-
**Filtering:**
|
|
1652
|
-
- **
|
|
1653
|
-
- **
|
|
1654
|
-
- **
|
|
1862
|
+
**Filtering (14 filter types):**
|
|
1863
|
+
- **engraving** - Show only products that support engraving/personalization
|
|
1864
|
+
- **presale** - Show only pre-order products
|
|
1865
|
+
- **fulfillment** - Filter by delivery type (shipping, onDemand)
|
|
1866
|
+
- **price** - Filter by price range
|
|
1867
|
+
- **brands** - Filter by brand
|
|
1868
|
+
- **categories** - Filter by category
|
|
1869
|
+
- **flavor** - Filter by flavor profile
|
|
1870
|
+
- **region** - Filter by region
|
|
1871
|
+
- **variety** - Filter by variety (e.g., Cabernet Sauvignon)
|
|
1872
|
+
- **vintage** - Filter by vintage year
|
|
1873
|
+
- **country** - Filter by country of origin
|
|
1874
|
+
- **appellation** - Filter by appellation
|
|
1875
|
+
- **materials** - Filter by material type
|
|
1876
|
+
- **sizes** - Filter by product size
|
|
1655
1877
|
|
|
1656
1878
|
**Smart Filter Logic:**
|
|
1657
|
-
- When "Same-Day Delivery" is selected,
|
|
1658
|
-
- When
|
|
1879
|
+
- When "Same-Day Delivery" is selected, engraving and presale filters are automatically disabled
|
|
1880
|
+
- When engraving or presale is enabled, same-day delivery is automatically disabled
|
|
1659
1881
|
- Filters work together intelligently to show only compatible product combinations
|
|
1660
1882
|
|
|
1661
1883
|
**Infinite Scroll:**
|
|
@@ -1695,10 +1917,9 @@ await client.injectProductList({
|
|
|
1695
1917
|
```html
|
|
1696
1918
|
<div id="category-products"
|
|
1697
1919
|
data-liquid-commerce-elements-products-list
|
|
1698
|
-
data-card="standard"
|
|
1699
1920
|
data-rows="4"
|
|
1700
1921
|
data-columns="4"
|
|
1701
|
-
data-filters="
|
|
1922
|
+
data-filters="engraving,fulfillment,price,brands"
|
|
1702
1923
|
data-product-url="/products/{upc}">
|
|
1703
1924
|
</div>
|
|
1704
1925
|
|
|
@@ -1710,22 +1931,32 @@ await client.injectProductList({
|
|
|
1710
1931
|
></script>
|
|
1711
1932
|
```
|
|
1712
1933
|
|
|
1713
|
-
#### Example: Search Results
|
|
1934
|
+
#### Example: Search Results with Sidebar Filters
|
|
1714
1935
|
|
|
1715
1936
|
```js
|
|
1716
1937
|
const client = await Elements('YOUR_API_KEY', {
|
|
1717
1938
|
env: 'production'
|
|
1718
1939
|
});
|
|
1719
1940
|
|
|
1941
|
+
// Inject search bar
|
|
1942
|
+
await client.injectProductListSearch({
|
|
1943
|
+
containerId: 'search-bar'
|
|
1944
|
+
});
|
|
1945
|
+
|
|
1946
|
+
// Inject product grid
|
|
1720
1947
|
await client.injectProductList({
|
|
1721
1948
|
containerId: 'search-results',
|
|
1722
1949
|
rows: 6,
|
|
1723
1950
|
columns: 3,
|
|
1724
|
-
|
|
1725
|
-
fillCard: true,
|
|
1726
|
-
filters: ['delivery-options'],
|
|
1951
|
+
filters: ['fulfillment', 'price', 'brands', 'categories'],
|
|
1727
1952
|
productUrl: '/search?q={grouping}'
|
|
1728
1953
|
});
|
|
1954
|
+
|
|
1955
|
+
// Inject sidebar filters
|
|
1956
|
+
await client.injectProductListFilters({
|
|
1957
|
+
containerId: 'filters-sidebar',
|
|
1958
|
+
filters: ['price', 'brands', 'categories', 'variety']
|
|
1959
|
+
});
|
|
1729
1960
|
```
|
|
1730
1961
|
|
|
1731
1962
|
**Use cases:**
|
|
@@ -2282,7 +2513,7 @@ Only inject components when needed:
|
|
|
2282
2513
|
// ❌ Don't inject all components upfront
|
|
2283
2514
|
await client.injectProductElement([/* 50 products */]);
|
|
2284
2515
|
await client.injectCartElement('cart');
|
|
2285
|
-
await client.injectCheckoutElement('checkout');
|
|
2516
|
+
await client.injectCheckoutElement({ containerId: 'checkout' });
|
|
2286
2517
|
|
|
2287
2518
|
// ✅ Inject components as user navigates
|
|
2288
2519
|
// On product page:
|
|
@@ -2292,7 +2523,7 @@ await client.injectProductElement([{ containerId: 'pdp', identifier: productId }
|
|
|
2292
2523
|
await client.injectCartElement('cart');
|
|
2293
2524
|
|
|
2294
2525
|
// On checkout (when user proceeds):
|
|
2295
|
-
await client.injectCheckoutElement('checkout');
|
|
2526
|
+
await client.injectCheckoutElement({ containerId: 'checkout' });
|
|
2296
2527
|
```
|
|
2297
2528
|
|
|
2298
2529
|
### Reuse Client Instance
|