@liquidcommerce/elements-sdk 2.7.0 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -2750
- package/dist/index.checkout.esm.js +6898 -6837
- package/dist/index.esm.js +11463 -10993
- package/dist/types/auto-initialize/shared-utils.d.ts +5 -0
- package/dist/types/constants/core.constant.d.ts +0 -4
- package/dist/types/core/base-component.service.d.ts +2 -1
- package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +1 -0
- package/dist/types/enums/core.enum.d.ts +11 -0
- package/dist/types/interfaces/configs/product-list.interface.d.ts +2 -2
- package/dist/types/interfaces/core.interface.d.ts +5 -4
- package/dist/types/modules/address/address-input.component.d.ts +11 -0
- package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
- package/dist/types/modules/product-list/components/card-components/index.d.ts +3 -0
- package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +8 -0
- package/dist/types/modules/product-list/components/card-components/product-fulfillments.d.ts +2 -0
- package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +13 -0
- package/dist/types/modules/product-list/components/card-components/product-title.d.ts +6 -0
- package/dist/types/modules/product-list/components/index.d.ts +1 -0
- package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +5 -1
- package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +28 -0
- package/dist/types/modules/product-list/components/product-list-retailers.component.d.ts +10 -2
- package/dist/types/modules/product-list/product-list-card.component.d.ts +0 -5
- package/dist/types/modules/product-list/product-list.commands.d.ts +11 -2
- package/dist/types/modules/product-list/product-list.interface.d.ts +1 -0
- package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +11 -2
- package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
- package/dist/types/utils/dom-compat.d.ts +2 -0
- package/docs/gitbook/actions.md +964 -0
- package/docs/gitbook/address.md +48 -0
- package/docs/gitbook/cart.md +65 -0
- package/docs/gitbook/checkout.md +131 -0
- package/docs/gitbook/events.md +1765 -0
- package/docs/gitbook/overview.md +166 -0
- package/docs/gitbook/product.md +64 -0
- package/docs/gitbook/quick-start-guide.md +393 -0
- package/docs/v1/README.md +210 -0
- package/docs/v1/api/actions/address-actions.md +281 -0
- package/docs/v1/api/actions/cart-actions.md +337 -0
- package/docs/v1/api/actions/checkout-actions.md +387 -0
- package/docs/v1/api/actions/product-actions.md +115 -0
- package/docs/v1/api/client.md +482 -0
- package/docs/v1/api/configuration.md +1 -0
- package/docs/v1/api/injection-methods.md +247 -0
- package/docs/v1/api/typescript-types.md +1 -0
- package/docs/v1/api/ui-helpers.md +200 -0
- package/docs/v1/examples/advanced-patterns.md +96 -0
- package/docs/v1/examples/checkout-flow.md +91 -0
- package/docs/v1/examples/custom-theming.md +63 -0
- package/docs/v1/examples/multi-product-page.md +90 -0
- package/docs/v1/examples/simple-product-page.md +89 -0
- package/docs/v1/getting-started/concepts.md +507 -0
- package/docs/v1/getting-started/installation.md +328 -0
- package/docs/v1/getting-started/quick-start.md +405 -0
- package/docs/v1/guides/address-component.md +431 -0
- package/docs/v1/guides/best-practices.md +324 -0
- package/docs/v1/guides/cart-component.md +737 -0
- package/docs/v1/guides/checkout-component.md +672 -0
- package/docs/v1/guides/events.md +926 -0
- package/docs/v1/guides/product-component.md +686 -0
- package/docs/v1/guides/product-list-component.md +598 -0
- package/docs/v1/guides/theming.md +216 -0
- package/docs/v1/integration/angular.md +39 -0
- package/docs/v1/integration/laravel.md +41 -0
- package/docs/v1/integration/nextjs.md +60 -0
- package/docs/v1/integration/proxy-setup.md +89 -0
- package/docs/v1/integration/react.md +64 -0
- package/docs/v1/integration/vanilla-js.md +84 -0
- package/docs/v1/integration/vue.md +34 -0
- package/docs/v1/reference/browser-support.md +44 -0
- package/docs/v1/reference/error-handling.md +70 -0
- package/docs/v1/reference/performance.md +54 -0
- package/docs/v1/reference/troubleshooting.md +64 -0
- package/package.json +1 -1
- package/docs/ACTIONS.md +0 -1301
- package/docs/BROWSER_SUPPORT.md +0 -279
- package/docs/CONFIGURATION.md +0 -997
- package/docs/DOCUMENTATION_INDEX.md +0 -319
- package/docs/EVENTS.md +0 -798
- package/docs/PROXY.md +0 -228
- package/docs/THEMING.md +0 -681
- package/docs/TROUBLESHOOTING.md +0 -793
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Elements SDK
|
|
2
|
+
|
|
3
|
+
A lightweight, developer-facing guide to integrate LiquidCommerce Elements SDK into your site or app.
|
|
4
|
+
|
|
5
|
+
## What it is
|
|
6
|
+
Elements SDK is a Web Components-based e-commerce SDK that embeds product, cart, address, and checkout experiences into any website. It works with plain HTML or any framework and exposes a simple client + actions API.
|
|
7
|
+
|
|
8
|
+
## Core components
|
|
9
|
+
- Product: product detail display + add to cart
|
|
10
|
+
- Cart: slide-out cart drawer + promo codes
|
|
11
|
+
- Checkout: full checkout flow (drawer or hosted page)
|
|
12
|
+
- Address: delivery location and availability
|
|
13
|
+
|
|
14
|
+
## Quick start (CDN)
|
|
15
|
+
```html
|
|
16
|
+
<script
|
|
17
|
+
defer
|
|
18
|
+
data-liquid-commerce-elements
|
|
19
|
+
data-token="YOUR_API_KEY"
|
|
20
|
+
data-env="production"
|
|
21
|
+
data-container-1="product"
|
|
22
|
+
data-product-1="00619947000020"
|
|
23
|
+
type="text/javascript"
|
|
24
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
25
|
+
></script>
|
|
26
|
+
|
|
27
|
+
<div id="product"></div>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick start (NPM)
|
|
31
|
+
```bash
|
|
32
|
+
npm install @liquidcommerce/elements-sdk
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
37
|
+
|
|
38
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
39
|
+
await client.injectProductElement([
|
|
40
|
+
{ containerId: 'product', identifier: '00619947000020' }
|
|
41
|
+
]);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Initialization modes
|
|
45
|
+
- Declarative (CDN): data attributes on the script tag, auto-initialized
|
|
46
|
+
- Programmatic (NPM or CDN): call `Elements(...)` and inject components
|
|
47
|
+
|
|
48
|
+
The client is available globally as `window.elements` as soon as the SDK is ready.
|
|
49
|
+
|
|
50
|
+
## Quick Start Guide (auto-setup)
|
|
51
|
+
Most partners use the auto-setup approach because it is the fastest to implement. It supports rich configuration via data attributes, including product injection, cart buttons, checkout, query param handling, and more.
|
|
52
|
+
|
|
53
|
+
See [Quick Start Guide](./quick-start-guide.md) for the complete list of supported attributes and combinations.
|
|
54
|
+
|
|
55
|
+
## Configuration basics
|
|
56
|
+
```js
|
|
57
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
58
|
+
env: 'production', // development | staging | production
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Client surface (exposed methods)
|
|
63
|
+
After initialization, the client exposes three main groups: injection methods, `actions`, and `ui` helpers, plus component management.
|
|
64
|
+
|
|
65
|
+
### Injection methods
|
|
66
|
+
Use these to mount SDK components into your DOM. Each method is shown with a minimal example.
|
|
67
|
+
|
|
68
|
+
#### `injectProductElement(params[])`
|
|
69
|
+
Inject one or more product components by container ID + product identifier.
|
|
70
|
+
```js
|
|
71
|
+
await client.injectProductElement([
|
|
72
|
+
{ containerId: 'product-1', identifier: '00619947000020' },
|
|
73
|
+
{ containerId: 'product-2', identifier: '08504405135' }
|
|
74
|
+
]);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### `injectAddressElement(containerId, options?)`
|
|
78
|
+
Inject a standalone address component (optional callbacks like `onAddressSet`).
|
|
79
|
+
```js
|
|
80
|
+
await client.injectAddressElement('address', {
|
|
81
|
+
onAddressSet: (address) => console.log(address)
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### `injectCartElement(containerId)`
|
|
86
|
+
Inject a standalone cart component (rare; cart drawer is automatic).
|
|
87
|
+
```js
|
|
88
|
+
await client.injectCartElement('cart');
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### `injectCheckoutElement(params)`
|
|
92
|
+
Inject a hosted checkout into a container.
|
|
93
|
+
```js
|
|
94
|
+
await client.injectCheckoutElement({
|
|
95
|
+
containerId: 'checkout',
|
|
96
|
+
checkoutId: 'checkout_abc123',
|
|
97
|
+
hideHeader: false
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
### Actions (`client.actions.*`)
|
|
103
|
+
Actions are programmatic controls for state changes and flows. The full list with details is in [Actions](./actions.md).
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
// Example: add to cart and open cart
|
|
107
|
+
await window.elements.actions.cart.addProduct([
|
|
108
|
+
{ identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }
|
|
109
|
+
], true);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### UI helpers (`client.ui.*`)
|
|
113
|
+
Helpers for common cart UI elements that stay in sync automatically.
|
|
114
|
+
|
|
115
|
+
#### `ui.cartButton(containerId, showItemsCount?)`
|
|
116
|
+
Renders a cart button in a container.
|
|
117
|
+
```js
|
|
118
|
+
window.elements.ui.cartButton('header-cart', true);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### `ui.floatingCartButton(showItemsCount?)`
|
|
122
|
+
Renders a floating cart button (bottom-right).
|
|
123
|
+
```js
|
|
124
|
+
window.elements.ui.floatingCartButton(true);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### `ui.cartSubtotal(elementId)`
|
|
128
|
+
Keeps a DOM element updated with cart subtotal.
|
|
129
|
+
```html
|
|
130
|
+
<span id="cart-total"></span>
|
|
131
|
+
```
|
|
132
|
+
```js
|
|
133
|
+
window.elements.ui.cartSubtotal('cart-total');
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### `ui.cartItemsCount(elementId, { hideZero })`
|
|
137
|
+
Keeps a DOM element updated with item count.
|
|
138
|
+
```html
|
|
139
|
+
<span id="items-count"></span>
|
|
140
|
+
```
|
|
141
|
+
```js
|
|
142
|
+
window.elements.ui.cartItemsCount('items-count', { hideZero: true });
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Component management
|
|
146
|
+
You can inspect and re-render injected components.
|
|
147
|
+
|
|
148
|
+
- `getInjectedComponents()`
|
|
149
|
+
Returns a map of injected components keyed by container ID.
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
const components = client.getInjectedComponents();
|
|
153
|
+
const productComponent = components.get('product-1');
|
|
154
|
+
|
|
155
|
+
productComponent.getType(); // 'product'
|
|
156
|
+
productComponent.getElement(); // underlying element
|
|
157
|
+
productComponent.rerender(); // force re-render
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Recommended flow
|
|
161
|
+
1. Initialize the client
|
|
162
|
+
2. Inject product(s)
|
|
163
|
+
3. Let the cart drawer handle checkout by default
|
|
164
|
+
4. Use actions + events to track analytics and UI updates
|
|
165
|
+
|
|
166
|
+
For details, see the component pages: Product, Cart, Checkout, Address, Actions, Events.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Product
|
|
2
|
+
|
|
3
|
+
The Product component renders a complete product view with images, pricing, fulfillment options, and add-to-cart.
|
|
4
|
+
|
|
5
|
+
## What you get
|
|
6
|
+
- Image carousel
|
|
7
|
+
- Name, description, pricing
|
|
8
|
+
- Size selection (if applicable)
|
|
9
|
+
- Fulfillment type selection (shipping or on-demand)
|
|
10
|
+
- Retailer selection (when multiple retailers are available)
|
|
11
|
+
- Personalization/engraving (when supported)
|
|
12
|
+
- Quantity controls
|
|
13
|
+
- Location-based availability and pricing
|
|
14
|
+
|
|
15
|
+
## Add a product (CDN, declarative)
|
|
16
|
+
```html
|
|
17
|
+
<script
|
|
18
|
+
defer
|
|
19
|
+
data-liquid-commerce-elements
|
|
20
|
+
data-token="YOUR_API_KEY"
|
|
21
|
+
data-env="production"
|
|
22
|
+
data-container-1="product"
|
|
23
|
+
data-product-1="00619947000020"
|
|
24
|
+
type="text/javascript"
|
|
25
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
26
|
+
></script>
|
|
27
|
+
|
|
28
|
+
<div id="product"></div>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Add a product (programmatic)
|
|
32
|
+
```js
|
|
33
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
34
|
+
await client.injectProductElement([
|
|
35
|
+
{ containerId: 'product', identifier: '00619947000020' }
|
|
36
|
+
]);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Identifiers
|
|
40
|
+
Use any of the supported identifiers:
|
|
41
|
+
- UPC
|
|
42
|
+
- Grouping ID
|
|
43
|
+
|
|
44
|
+
The SDK resolves the correct product automatically.
|
|
45
|
+
|
|
46
|
+
## Product actions
|
|
47
|
+
```js
|
|
48
|
+
const product = window.elements.actions.product.getDetails('00619947000020');
|
|
49
|
+
console.log(product.name, product.price);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Product events (examples)
|
|
53
|
+
```js
|
|
54
|
+
window.addEventListener('lce:actions.product_loaded', (event) => {
|
|
55
|
+
const { identifier, name, price } = event.detail.data;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
window.addEventListener('lce:actions.product_add_to_cart', (event) => {
|
|
59
|
+
const { identifier, quantity, fulfillmentType } = event.detail.data;
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Address requirement
|
|
64
|
+
If an address is required for availability, the SDK automatically prompts the user to set it before adding to cart.
|
|
@@ -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
|
+
```
|