@liquidcommerce/elements-sdk 2.6.0-beta.38 → 2.6.0-beta.39
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 +156 -2731
- package/dist/index.checkout.esm.js +6747 -6747
- package/dist/index.esm.js +10658 -10658
- package/docs/actions.md +320 -0
- package/docs/address.md +242 -0
- package/docs/cart.md +387 -0
- package/docs/checkout.md +420 -0
- package/docs/{CONFIGURATION.md → configuration.md} +34 -14
- package/docs/events.md +181 -0
- package/docs/product-list.md +311 -0
- package/docs/product.md +250 -0
- package/docs/{THEMING.md → theming.md} +3 -2
- package/docs/{TROUBLESHOOTING.md → troubleshooting.md} +6 -6
- package/package.json +1 -1
- package/docs/ACTIONS.md +0 -1301
- package/docs/DOCUMENTATION_INDEX.md +0 -319
- package/docs/EVENTS.md +0 -798
- /package/docs/{BROWSER_SUPPORT.md → browser-support.md} +0 -0
- /package/docs/{PROXY.md → proxy.md} +0 -0
package/docs/checkout.md
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
# Checkout
|
|
2
|
+
|
|
3
|
+
The checkout component handles the complete purchase flow - collecting customer information, processing payments, and showing order confirmation. It can run as a slide-out drawer from the cart or as a standalone hosted page.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The checkout element guides customers through:
|
|
8
|
+
- Contact information collection
|
|
9
|
+
- Delivery address confirmation
|
|
10
|
+
- Payment processing (via Stripe)
|
|
11
|
+
- Promo codes and gift cards
|
|
12
|
+
- Gift options and messaging
|
|
13
|
+
- Marketing opt-ins
|
|
14
|
+
- Age verification
|
|
15
|
+
- Order confirmation
|
|
16
|
+
|
|
17
|
+
After a successful purchase, customers see a confirmation screen with their order details.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Declarative Setup (HTML Attributes)
|
|
22
|
+
|
|
23
|
+
### Default Drawer Checkout
|
|
24
|
+
|
|
25
|
+
By default, checkout opens as a drawer when customers click "Checkout" from the cart. No additional configuration needed.
|
|
26
|
+
|
|
27
|
+
### Hosted Checkout (External Page)
|
|
28
|
+
|
|
29
|
+
Redirect to a dedicated checkout page instead of using the drawer:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<script
|
|
33
|
+
defer
|
|
34
|
+
type="text/javascript"
|
|
35
|
+
data-liquid-commerce-elements
|
|
36
|
+
data-token="YOUR_API_KEY"
|
|
37
|
+
data-env="production"
|
|
38
|
+
data-checkout-url="https://yoursite.com/checkout"
|
|
39
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
40
|
+
></script>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
When customers click "Checkout", they're redirected to your checkout URL with a checkout token.
|
|
44
|
+
|
|
45
|
+
### Checkout-Only Page
|
|
46
|
+
|
|
47
|
+
For dedicated checkout pages, use the checkout-only build:
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<div id="checkout-container"></div>
|
|
51
|
+
|
|
52
|
+
<script
|
|
53
|
+
defer
|
|
54
|
+
type="text/javascript"
|
|
55
|
+
data-liquid-commerce-checkout
|
|
56
|
+
data-token="YOUR_API_KEY"
|
|
57
|
+
data-env="production"
|
|
58
|
+
data-container="checkout-container"
|
|
59
|
+
src="https://assets-elements.liquidcommerce.us/checkout/elements.js"
|
|
60
|
+
></script>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This lighter build only includes checkout components, reducing bundle size for dedicated checkout pages.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Programmatic Setup (JavaScript API)
|
|
68
|
+
|
|
69
|
+
Inject the checkout element for maximum control.
|
|
70
|
+
|
|
71
|
+
### Basic Injection
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
75
|
+
|
|
76
|
+
const component = await client.injectCheckoutElement({
|
|
77
|
+
containerId: 'checkout-container'
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### With Options
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
const component = await client.injectCheckoutElement({
|
|
85
|
+
containerId: 'checkout-container',
|
|
86
|
+
checkoutId: 'chk_abc123', // Load a specific checkout session
|
|
87
|
+
hideHeader: true // Hide header for embedded checkout
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Parameters
|
|
92
|
+
|
|
93
|
+
| Parameter | Type | Required | Description |
|
|
94
|
+
|-----------|------|----------|-------------|
|
|
95
|
+
| `containerId` | string | Yes | ID of the container element |
|
|
96
|
+
| `checkoutId` | string | No | Checkout token to resume a session |
|
|
97
|
+
| `hideHeader` | boolean | No | Hide the checkout header |
|
|
98
|
+
|
|
99
|
+
### TypeScript Types
|
|
100
|
+
|
|
101
|
+
For TypeScript users, import types directly from the package:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import type {
|
|
105
|
+
ILiquidCommerceElementsClient,
|
|
106
|
+
ILiquidCommerceElementsConfig,
|
|
107
|
+
IAddProductParams,
|
|
108
|
+
ICheckoutActions
|
|
109
|
+
} from '@liquidcommerce/elements-sdk';
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Checkout-Only Build (NPM)
|
|
113
|
+
|
|
114
|
+
For dedicated checkout pages with smaller bundle:
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
import { ElementsCheckout } from '@liquidcommerce/elements-sdk/checkout';
|
|
118
|
+
|
|
119
|
+
const client = await ElementsCheckout('YOUR_API_KEY', { env: 'production' });
|
|
120
|
+
await client.injectCheckoutElement({ containerId: 'checkout-container' });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Actions
|
|
126
|
+
|
|
127
|
+
Control checkout behavior and pre-fill customer data.
|
|
128
|
+
|
|
129
|
+
### Open / Close / Toggle
|
|
130
|
+
|
|
131
|
+
```javascript
|
|
132
|
+
// Open checkout drawer
|
|
133
|
+
window.elements.actions.checkout.openCheckout();
|
|
134
|
+
|
|
135
|
+
// Close checkout drawer
|
|
136
|
+
window.elements.actions.checkout.closeCheckout();
|
|
137
|
+
|
|
138
|
+
// Toggle checkout drawer
|
|
139
|
+
window.elements.actions.checkout.toggleCheckout();
|
|
140
|
+
|
|
141
|
+
// Navigate to exit URL (for hosted checkout)
|
|
142
|
+
window.elements.actions.checkout.exitCheckout();
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Add Products Directly to Checkout
|
|
146
|
+
|
|
147
|
+
Skip the cart and go straight to checkout:
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
await window.elements.actions.checkout.addProduct(
|
|
151
|
+
[
|
|
152
|
+
{
|
|
153
|
+
identifier: '00619947000020',
|
|
154
|
+
fulfillmentType: 'shipping',
|
|
155
|
+
quantity: 1
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
true // Open checkout after adding
|
|
159
|
+
);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Promo Codes
|
|
163
|
+
|
|
164
|
+
```javascript
|
|
165
|
+
// Apply promo code
|
|
166
|
+
await window.elements.actions.checkout.applyPromoCode('SAVE10');
|
|
167
|
+
|
|
168
|
+
// Remove promo code
|
|
169
|
+
await window.elements.actions.checkout.removePromoCode();
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Gift Cards
|
|
173
|
+
|
|
174
|
+
```javascript
|
|
175
|
+
// Apply gift card
|
|
176
|
+
await window.elements.actions.checkout.applyGiftCard('GIFT-XXXX-XXXX');
|
|
177
|
+
|
|
178
|
+
// Remove gift card
|
|
179
|
+
await window.elements.actions.checkout.removeGiftCard('GIFT-XXXX-XXXX');
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Form Controls
|
|
183
|
+
|
|
184
|
+
Pre-fill or toggle checkout form options:
|
|
185
|
+
|
|
186
|
+
```javascript
|
|
187
|
+
// Toggle gift mode
|
|
188
|
+
await window.elements.actions.checkout.toggleIsGift(true);
|
|
189
|
+
|
|
190
|
+
// Use shipping address for billing
|
|
191
|
+
await window.elements.actions.checkout.toggleBillingSameAsShipping(true);
|
|
192
|
+
|
|
193
|
+
// Set marketing preferences
|
|
194
|
+
await window.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
|
|
195
|
+
await window.elements.actions.checkout.toggleMarketingPreferences('canSms', false);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Pre-fill Customer Information
|
|
199
|
+
|
|
200
|
+
Pre-fill forms for logged-in customers:
|
|
201
|
+
|
|
202
|
+
```javascript
|
|
203
|
+
// Customer contact info
|
|
204
|
+
window.elements.actions.checkout.updateCustomerInfo({
|
|
205
|
+
firstName: 'John',
|
|
206
|
+
lastName: 'Doe',
|
|
207
|
+
email: 'john@example.com',
|
|
208
|
+
phone: '555-123-4567'
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Billing address (if different from shipping)
|
|
212
|
+
window.elements.actions.checkout.updateBillingInfo({
|
|
213
|
+
firstName: 'John',
|
|
214
|
+
lastName: 'Doe',
|
|
215
|
+
street1: '123 Billing St',
|
|
216
|
+
city: 'New York',
|
|
217
|
+
state: 'NY',
|
|
218
|
+
zipCode: '10001'
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// Gift recipient info
|
|
222
|
+
window.elements.actions.checkout.updateGiftInfo({
|
|
223
|
+
recipientName: 'Jane Smith',
|
|
224
|
+
senderName: 'John Doe',
|
|
225
|
+
giftMessage: 'Happy Birthday!'
|
|
226
|
+
});
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Get Checkout Details
|
|
230
|
+
|
|
231
|
+
Retrieve current checkout state:
|
|
232
|
+
|
|
233
|
+
```javascript
|
|
234
|
+
const checkout = window.elements.actions.checkout.getDetails();
|
|
235
|
+
|
|
236
|
+
console.log(checkout.subtotal);
|
|
237
|
+
console.log(checkout.total);
|
|
238
|
+
console.log(checkout.items);
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Events
|
|
244
|
+
|
|
245
|
+
Track checkout progress and handle completion.
|
|
246
|
+
|
|
247
|
+
### Subscribing to Events
|
|
248
|
+
|
|
249
|
+
```javascript
|
|
250
|
+
window.addEventListener('lce:actions.checkout_submit_completed', (event) => {
|
|
251
|
+
const { orderNumber, orderTotal } = event.detail.data;
|
|
252
|
+
console.log('Order placed:', orderNumber);
|
|
253
|
+
});
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Lifecycle Events
|
|
257
|
+
|
|
258
|
+
| Event | Description | Key Data |
|
|
259
|
+
|-------|-------------|----------|
|
|
260
|
+
| `checkout_loaded` | Checkout ready | Full checkout state |
|
|
261
|
+
| `checkout_opened` | Drawer opened | boolean |
|
|
262
|
+
| `checkout_closed` | Drawer closed | boolean |
|
|
263
|
+
| `checkout_failed` | Operation failed | message |
|
|
264
|
+
|
|
265
|
+
### Form Events
|
|
266
|
+
|
|
267
|
+
| Event | Description | Key Data |
|
|
268
|
+
|-------|-------------|----------|
|
|
269
|
+
| `checkout_customer_information_updated` | Customer form filled | cartId (data is secure) |
|
|
270
|
+
| `checkout_billing_information_updated` | Billing form filled | cartId (data is secure) |
|
|
271
|
+
| `checkout_gift_information_updated` | Gift form filled | cartId (data is secure) |
|
|
272
|
+
| `checkout_is_gift_toggled` | Gift option changed | cartId, isActive |
|
|
273
|
+
| `checkout_billing_same_as_shipping_toggled` | Address option changed | cartId, isActive |
|
|
274
|
+
| `checkout_marketing_preferences_toggled` | Opt-in changed | cartId, fieldName, isActive |
|
|
275
|
+
|
|
276
|
+
**Note:** Form update events only indicate completion status, not actual customer data (for security).
|
|
277
|
+
|
|
278
|
+
### Item Events
|
|
279
|
+
|
|
280
|
+
| Event | Description | Key Data |
|
|
281
|
+
|-------|-------------|----------|
|
|
282
|
+
| `checkout_item_removed` | Item removed | cartId, cartItemId |
|
|
283
|
+
| `checkout_item_quantity_increase` | Quantity increased | cartId, cartItemId, quantity |
|
|
284
|
+
| `checkout_item_quantity_decrease` | Quantity decreased | cartId, cartItemId, quantity |
|
|
285
|
+
| `checkout_item_engraving_updated` | Personalization changed | cartId, cartItemId, engravingLines |
|
|
286
|
+
| `checkout_tip_updated` | Delivery tip changed | cartId, deliveryTips |
|
|
287
|
+
|
|
288
|
+
### Submit Events
|
|
289
|
+
|
|
290
|
+
| Event | Description | Key Data |
|
|
291
|
+
|-------|-------------|----------|
|
|
292
|
+
| `checkout_submit_started` | Payment processing | started: boolean |
|
|
293
|
+
| `checkout_submit_completed` | Order placed | orderNumber, orderTotal |
|
|
294
|
+
| `checkout_submit_failed` | Order failed | message |
|
|
295
|
+
|
|
296
|
+
### Discount Events
|
|
297
|
+
|
|
298
|
+
| Event | Description | Key Data |
|
|
299
|
+
|-------|-------------|----------|
|
|
300
|
+
| `checkout_promo_code_applied` | Discount applied | cartId, discount, newTotal |
|
|
301
|
+
| `checkout_promo_code_removed` | Discount removed | cartId, newTotal |
|
|
302
|
+
| `checkout_promo_code_failed` | Discount rejected | cartId, error |
|
|
303
|
+
| `checkout_gift_card_applied` | Gift card applied | cartId, newTotal |
|
|
304
|
+
| `checkout_gift_card_removed` | Gift card removed | cartId, newTotal |
|
|
305
|
+
| `checkout_gift_card_failed` | Gift card rejected | cartId, error |
|
|
306
|
+
|
|
307
|
+
### Product Events
|
|
308
|
+
|
|
309
|
+
| Event | Description | Key Data |
|
|
310
|
+
|-------|-------------|----------|
|
|
311
|
+
| `checkout_product_add_success` | Programmatic add succeeded | cartId, itemsAdded, identifiers |
|
|
312
|
+
| `checkout_product_add_failed` | Programmatic add failed | cartId, identifiers, error |
|
|
313
|
+
|
|
314
|
+
### Example: Order Completion Tracking
|
|
315
|
+
|
|
316
|
+
```javascript
|
|
317
|
+
// Track successful orders
|
|
318
|
+
window.addEventListener('lce:actions.checkout_submit_completed', (event) => {
|
|
319
|
+
const { orderNumber, orderTotal } = event.detail.data;
|
|
320
|
+
|
|
321
|
+
// Send to analytics
|
|
322
|
+
analytics.track('Order Completed', {
|
|
323
|
+
orderId: orderNumber,
|
|
324
|
+
revenue: orderTotal
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
// Redirect to thank you page
|
|
328
|
+
window.location.href = `/thank-you?order=${orderNumber}`;
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
// Track failed orders
|
|
332
|
+
window.addEventListener('lce:actions.checkout_submit_failed', (event) => {
|
|
333
|
+
analytics.track('Checkout Failed', {
|
|
334
|
+
error: event.detail.data.message
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Use Cases
|
|
342
|
+
|
|
343
|
+
### Express Checkout for Returning Customers
|
|
344
|
+
|
|
345
|
+
Pre-fill everything for logged-in users:
|
|
346
|
+
|
|
347
|
+
```javascript
|
|
348
|
+
// When user reaches checkout and is logged in
|
|
349
|
+
if (currentUser) {
|
|
350
|
+
window.elements.actions.checkout.updateCustomerInfo({
|
|
351
|
+
firstName: currentUser.firstName,
|
|
352
|
+
lastName: currentUser.lastName,
|
|
353
|
+
email: currentUser.email,
|
|
354
|
+
phone: currentUser.phone
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// Enable billing same as shipping by default
|
|
358
|
+
await window.elements.actions.checkout.toggleBillingSameAsShipping(true);
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Skip Cart Flow
|
|
363
|
+
|
|
364
|
+
Go directly from product page to checkout:
|
|
365
|
+
|
|
366
|
+
```javascript
|
|
367
|
+
document.querySelector('#buy-now').addEventListener('click', async () => {
|
|
368
|
+
await window.elements.actions.checkout.addProduct([
|
|
369
|
+
{
|
|
370
|
+
identifier: currentProductId,
|
|
371
|
+
fulfillmentType: selectedFulfillment,
|
|
372
|
+
quantity: selectedQuantity
|
|
373
|
+
}
|
|
374
|
+
], true); // Opens checkout immediately
|
|
375
|
+
});
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Auto-Apply Best Discount
|
|
379
|
+
|
|
380
|
+
```javascript
|
|
381
|
+
// Check for URL promo or user's best available code
|
|
382
|
+
const promoCode = urlParams.get('promo') || currentUser?.bestPromoCode;
|
|
383
|
+
|
|
384
|
+
if (promoCode) {
|
|
385
|
+
window.addEventListener('lce:actions.checkout_loaded', async () => {
|
|
386
|
+
await window.elements.actions.checkout.applyPromoCode(promoCode);
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Customization
|
|
394
|
+
|
|
395
|
+
Style checkout through theme configuration.
|
|
396
|
+
|
|
397
|
+
```javascript
|
|
398
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
399
|
+
customTheme: {
|
|
400
|
+
checkout: {
|
|
401
|
+
// Checkout-specific theme options
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
See [theming.md](./theming.md) for available checkout theme options including:
|
|
408
|
+
- Form field styling
|
|
409
|
+
- Button colors
|
|
410
|
+
- Completion screen customization
|
|
411
|
+
- Layout options
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## See Also
|
|
416
|
+
|
|
417
|
+
- [Cart](./cart.md) - Shopping cart component
|
|
418
|
+
- [Actions Reference](./actions.md) - All available actions
|
|
419
|
+
- [Events Reference](./events.md) - All available events
|
|
420
|
+
- [Theming Guide](./theming.md) - Customization options
|
|
@@ -86,7 +86,7 @@ isBuilder: true // Enables builder.* methods
|
|
|
86
86
|
**Type:** `object`
|
|
87
87
|
**Default:** `{}`
|
|
88
88
|
|
|
89
|
-
Custom theme configuration. See [`
|
|
89
|
+
Custom theme configuration. See [`theming.md`](./theming.md) for complete reference.
|
|
90
90
|
|
|
91
91
|
```javascript
|
|
92
92
|
customTheme: {
|
|
@@ -191,7 +191,7 @@ headers: {
|
|
|
191
191
|
}
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
-
See [`
|
|
194
|
+
See [`proxy.md`](./proxy.md) for implementation guide.
|
|
195
195
|
|
|
196
196
|
### `promoTicker`
|
|
197
197
|
|
|
@@ -300,6 +300,8 @@ When using auto-initialization, configure via `data-` attributes on the script t
|
|
|
300
300
|
|
|
301
301
|
```html
|
|
302
302
|
<script
|
|
303
|
+
defer
|
|
304
|
+
type="text/javascript"
|
|
303
305
|
data-liquid-commerce-elements
|
|
304
306
|
data-token="YOUR_API_KEY"
|
|
305
307
|
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
@@ -444,7 +446,9 @@ data-cart-button-hidden
|
|
|
444
446
|
|
|
445
447
|
**Simple cart button (no badge):**
|
|
446
448
|
```html
|
|
447
|
-
<script
|
|
449
|
+
<script
|
|
450
|
+
defer
|
|
451
|
+
type="text/javascript"
|
|
448
452
|
data-liquid-commerce-elements
|
|
449
453
|
data-token="your-api-key"
|
|
450
454
|
data-cart-button="header-cart"
|
|
@@ -454,7 +458,9 @@ data-cart-button-hidden
|
|
|
454
458
|
|
|
455
459
|
**Cart button with item count badge:**
|
|
456
460
|
```html
|
|
457
|
-
<script
|
|
461
|
+
<script
|
|
462
|
+
defer
|
|
463
|
+
type="text/javascript"
|
|
458
464
|
data-liquid-commerce-elements
|
|
459
465
|
data-token="your-api-key"
|
|
460
466
|
data-cart-badge-button="header-cart"
|
|
@@ -465,7 +471,9 @@ data-cart-button-hidden
|
|
|
465
471
|
**Using position-prefixed selectors:**
|
|
466
472
|
```html
|
|
467
473
|
<!-- Place inside the target element (default) -->
|
|
468
|
-
<script
|
|
474
|
+
<script
|
|
475
|
+
defer
|
|
476
|
+
type="text/javascript"
|
|
469
477
|
data-liquid-commerce-elements
|
|
470
478
|
data-token="your-api-key"
|
|
471
479
|
data-cart-badge-button="inside:.header .nav-links"
|
|
@@ -473,7 +481,9 @@ data-cart-button-hidden
|
|
|
473
481
|
</script>
|
|
474
482
|
|
|
475
483
|
<!-- Place above the target element -->
|
|
476
|
-
<script
|
|
484
|
+
<script
|
|
485
|
+
defer
|
|
486
|
+
type="text/javascript"
|
|
477
487
|
data-liquid-commerce-elements
|
|
478
488
|
data-token="your-api-key"
|
|
479
489
|
data-cart-button="above:.header .logo"
|
|
@@ -481,7 +491,9 @@ data-cart-button-hidden
|
|
|
481
491
|
</script>
|
|
482
492
|
|
|
483
493
|
<!-- Place below the target element -->
|
|
484
|
-
<script
|
|
494
|
+
<script
|
|
495
|
+
defer
|
|
496
|
+
type="text/javascript"
|
|
485
497
|
data-liquid-commerce-elements
|
|
486
498
|
data-token="your-api-key"
|
|
487
499
|
data-cart-badge-button="below:#main-navigation"
|
|
@@ -489,7 +501,9 @@ data-cart-button-hidden
|
|
|
489
501
|
</script>
|
|
490
502
|
|
|
491
503
|
<!-- Replace the target element -->
|
|
492
|
-
<script
|
|
504
|
+
<script
|
|
505
|
+
defer
|
|
506
|
+
type="text/javascript"
|
|
493
507
|
data-liquid-commerce-elements
|
|
494
508
|
data-token="your-api-key"
|
|
495
509
|
data-cart-button="replace:.old-cart-button"
|
|
@@ -499,7 +513,9 @@ data-cart-button-hidden
|
|
|
499
513
|
|
|
500
514
|
**No cart button:**
|
|
501
515
|
```html
|
|
502
|
-
<script
|
|
516
|
+
<script
|
|
517
|
+
defer
|
|
518
|
+
type="text/javascript"
|
|
503
519
|
data-liquid-commerce-elements
|
|
504
520
|
data-token="your-api-key"
|
|
505
521
|
data-cart-button-hidden
|
|
@@ -509,7 +525,9 @@ data-cart-button-hidden
|
|
|
509
525
|
|
|
510
526
|
**Default behavior (floating cart button with badge):**
|
|
511
527
|
```html
|
|
512
|
-
<script
|
|
528
|
+
<script
|
|
529
|
+
defer
|
|
530
|
+
type="text/javascript"
|
|
513
531
|
data-liquid-commerce-elements
|
|
514
532
|
data-token="your-api-key"
|
|
515
533
|
src="elements.js">
|
|
@@ -794,6 +812,8 @@ For hosted checkout pages, use the checkout-only build for a smaller bundle.
|
|
|
794
812
|
|
|
795
813
|
```html
|
|
796
814
|
<script
|
|
815
|
+
defer
|
|
816
|
+
type="text/javascript"
|
|
797
817
|
data-liquid-commerce-checkout
|
|
798
818
|
data-token="YOUR_API_KEY"
|
|
799
819
|
data-env="production"
|
|
@@ -990,8 +1010,8 @@ const client = await Elements(process.env.LCE_API_KEY, {
|
|
|
990
1010
|
|
|
991
1011
|
## Related Documentation
|
|
992
1012
|
|
|
993
|
-
- [Theming Guide](./
|
|
994
|
-
- [Proxy Setup](./
|
|
995
|
-
- [Actions Reference](./
|
|
996
|
-
- [Events Reference](./
|
|
1013
|
+
- [Theming Guide](./theming.md) - Complete theme configuration reference
|
|
1014
|
+
- [Proxy Setup](./proxy.md) - Proxy implementation guide
|
|
1015
|
+
- [Actions Reference](./actions.md) - Programmatic control API
|
|
1016
|
+
- [Events Reference](./events.md) - Event system and tracking
|
|
997
1017
|
|