@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,672 @@
|
|
|
1
|
+
# Checkout Component
|
|
2
|
+
|
|
3
|
+
The Checkout component provides a complete purchase flow including customer information collection, payment processing, and order confirmation.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Checkout component handles:
|
|
8
|
+
- Customer information (email, phone, address)
|
|
9
|
+
- Gift recipient details (optional)
|
|
10
|
+
- Payment processing (Stripe integration)
|
|
11
|
+
- Billing address
|
|
12
|
+
- Promo codes and gift cards
|
|
13
|
+
- Order summary and totals
|
|
14
|
+
- Marketing preferences
|
|
15
|
+
- Tip options
|
|
16
|
+
- Order confirmation
|
|
17
|
+
|
|
18
|
+
## Basic Usage
|
|
19
|
+
|
|
20
|
+
### Checkout Drawer (Default)
|
|
21
|
+
|
|
22
|
+
The checkout drawer opens automatically when users click "Checkout" from the cart. No additional setup required.
|
|
23
|
+
|
|
24
|
+
### Hosted Checkout Page
|
|
25
|
+
|
|
26
|
+
For a full-page checkout experience, inject checkout into a dedicated container:
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
30
|
+
|
|
31
|
+
await client.injectCheckoutElement({
|
|
32
|
+
containerId: 'checkout-container',
|
|
33
|
+
checkoutId: 'optional_checkout_id', // Optional: load specific checkout
|
|
34
|
+
hideHeader: false // Optional: hide checkout header
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### With URL Parameter
|
|
39
|
+
|
|
40
|
+
Configure checkout to load from URL parameter:
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<script
|
|
44
|
+
defer
|
|
45
|
+
data-liquid-commerce-elements
|
|
46
|
+
data-token="YOUR_API_KEY"
|
|
47
|
+
data-env="production"
|
|
48
|
+
data-checkout-container="checkout"
|
|
49
|
+
data-checkout-param="lce_checkout"
|
|
50
|
+
type="text/javascript"
|
|
51
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
52
|
+
></script>
|
|
53
|
+
|
|
54
|
+
<div id="checkout"></div>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Visit `https://yoursite.com/checkout?lce_checkout=checkout_abc123` to load that checkout.
|
|
58
|
+
|
|
59
|
+
### Redirect to Custom Checkout Page
|
|
60
|
+
|
|
61
|
+
Configure the cart to redirect to your checkout page instead of opening the drawer:
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
65
|
+
env: 'production',
|
|
66
|
+
checkout: {
|
|
67
|
+
pageUrl: 'https://yoursite.com/checkout?lce_checkout={token}'
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Or with data attributes:
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<script
|
|
76
|
+
defer
|
|
77
|
+
data-liquid-commerce-elements
|
|
78
|
+
data-token="YOUR_API_KEY"
|
|
79
|
+
data-env="production"
|
|
80
|
+
data-checkout-url="https://yoursite.com/checkout?lce_checkout={token}"
|
|
81
|
+
type="text/javascript"
|
|
82
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
83
|
+
></script>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The `{token}` placeholder is replaced with the checkout token.
|
|
87
|
+
|
|
88
|
+
## Checkout Actions
|
|
89
|
+
|
|
90
|
+
### Open Checkout
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
window.elements.actions.checkout.openCheckout();
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Close Checkout
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
window.elements.actions.checkout.closeCheckout();
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Toggle Checkout
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
window.elements.actions.checkout.toggleCheckout();
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Exit Checkout
|
|
109
|
+
|
|
110
|
+
Navigate away from checkout (requires `exitUrl` configuration):
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
window.elements.actions.checkout.exitCheckout();
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Configure exit URL:
|
|
117
|
+
|
|
118
|
+
```javascript
|
|
119
|
+
customTheme: {
|
|
120
|
+
checkout: {
|
|
121
|
+
layout: {
|
|
122
|
+
exitUrl: 'https://yoursite.com/shop'
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Add Product to Checkout
|
|
129
|
+
|
|
130
|
+
Skip the cart and go directly to checkout:
|
|
131
|
+
|
|
132
|
+
```javascript
|
|
133
|
+
await window.elements.actions.checkout.addProduct([
|
|
134
|
+
{
|
|
135
|
+
identifier: '00619947000020',
|
|
136
|
+
fulfillmentType: 'shipping',
|
|
137
|
+
quantity: 1
|
|
138
|
+
}
|
|
139
|
+
], true); // true = open checkout after adding
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Apply Promo Code
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
await window.elements.actions.checkout.applyPromoCode('WELCOME10');
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Remove Promo Code
|
|
149
|
+
|
|
150
|
+
```javascript
|
|
151
|
+
await window.elements.actions.checkout.removePromoCode();
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Apply Gift Card
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
await window.elements.actions.checkout.applyGiftCard('GIFT-1234-5678');
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Remove Gift Card
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
await window.elements.actions.checkout.removeGiftCard('GIFT-1234-5678');
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Toggle Gift Mode
|
|
167
|
+
|
|
168
|
+
Enable/disable "Send as Gift" mode:
|
|
169
|
+
|
|
170
|
+
```javascript
|
|
171
|
+
// Enable gift mode
|
|
172
|
+
await window.elements.actions.checkout.toggleIsGift(true);
|
|
173
|
+
|
|
174
|
+
// Disable gift mode
|
|
175
|
+
await window.elements.actions.checkout.toggleIsGift(false);
|
|
176
|
+
|
|
177
|
+
// Toggle current state
|
|
178
|
+
await window.elements.actions.checkout.toggleIsGift();
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Toggle Billing Same As Shipping
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
// Use shipping address for billing
|
|
185
|
+
await window.elements.actions.checkout.toggleBillingSameAsShipping(true);
|
|
186
|
+
|
|
187
|
+
// Use different billing address
|
|
188
|
+
await window.elements.actions.checkout.toggleBillingSameAsShipping(false);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Toggle Marketing Preferences
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
// Opt into email marketing
|
|
195
|
+
await window.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
|
|
196
|
+
|
|
197
|
+
// Opt into SMS marketing
|
|
198
|
+
await window.elements.actions.checkout.toggleMarketingPreferences('canSms', true);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Update Customer Information
|
|
202
|
+
|
|
203
|
+
Pre-fill customer information:
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
window.elements.actions.checkout.updateCustomerInfo({
|
|
207
|
+
firstName: 'John',
|
|
208
|
+
lastName: 'Doe',
|
|
209
|
+
email: 'john@example.com',
|
|
210
|
+
phone: '+15551234567',
|
|
211
|
+
birthDate: '123 Main St',
|
|
212
|
+
addressTwo: 'Apt 4',
|
|
213
|
+
company: 'Acme Corp'
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Available fields:**
|
|
218
|
+
- `firstName`, `lastName`
|
|
219
|
+
- `email`, `phone`
|
|
220
|
+
- `birthDate`, `addressTwo`
|
|
221
|
+
- `company`
|
|
222
|
+
|
|
223
|
+
### Update Gift Information
|
|
224
|
+
|
|
225
|
+
Pre-fill gift recipient information:
|
|
226
|
+
|
|
227
|
+
```javascript
|
|
228
|
+
window.elements.actions.checkout.updateGiftInfo({
|
|
229
|
+
firstName: 'Jane',
|
|
230
|
+
lastName: 'Smith',
|
|
231
|
+
email: 'jane@example.com',
|
|
232
|
+
phone: '+15559876543',
|
|
233
|
+
message: 'Happy Birthday!',
|
|
234
|
+
addressTwo: 'Suite 5B'
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Available fields:**
|
|
239
|
+
- `firstName`, `lastName`
|
|
240
|
+
- `email`, `phone`
|
|
241
|
+
- `message`
|
|
242
|
+
- `addressTwo`
|
|
243
|
+
|
|
244
|
+
### Update Billing Information
|
|
245
|
+
|
|
246
|
+
Pre-fill billing address:
|
|
247
|
+
|
|
248
|
+
```javascript
|
|
249
|
+
window.elements.actions.checkout.updateBillingInfo({
|
|
250
|
+
firstName: 'John',
|
|
251
|
+
lastName: 'Doe',
|
|
252
|
+
email: 'john@example.com',
|
|
253
|
+
phone: '+15551234567',
|
|
254
|
+
addressOne: '789 Elm St',
|
|
255
|
+
addressTwo: 'Floor 2',
|
|
256
|
+
city: 'Chicago',
|
|
257
|
+
state: 'IL',
|
|
258
|
+
zipCode: '60601'
|
|
259
|
+
});
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Available fields:**
|
|
263
|
+
- `firstName`, `lastName`
|
|
264
|
+
- `email`, `phone`, `company`
|
|
265
|
+
- `addressOne`, `addressTwo`
|
|
266
|
+
- `city`, `state`, `zipCode`
|
|
267
|
+
|
|
268
|
+
### Get Checkout Details
|
|
269
|
+
|
|
270
|
+
```javascript
|
|
271
|
+
const checkoutData = window.elements.actions.checkout.getDetails();
|
|
272
|
+
|
|
273
|
+
console.log(checkoutData);
|
|
274
|
+
// {
|
|
275
|
+
// token: 'abc123xyz',
|
|
276
|
+
// cartId: 'cart_abc123',
|
|
277
|
+
// items: [...],
|
|
278
|
+
// amounts: {
|
|
279
|
+
// subtotal: 9998,
|
|
280
|
+
// tax: 800,
|
|
281
|
+
// shipping: 500,
|
|
282
|
+
// tip: 200,
|
|
283
|
+
// total: 11498
|
|
284
|
+
// },
|
|
285
|
+
// customer: { ... },
|
|
286
|
+
// shippingAddress: { ... },
|
|
287
|
+
// isGift: false,
|
|
288
|
+
// ...
|
|
289
|
+
// }
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Events
|
|
293
|
+
|
|
294
|
+
### Checkout Lifecycle
|
|
295
|
+
|
|
296
|
+
```javascript
|
|
297
|
+
window.addEventListener('lce:actions.checkout_loaded', (event) => {
|
|
298
|
+
console.log('Checkout loaded');
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
window.addEventListener('lce:actions.checkout_opened', (event) => {
|
|
302
|
+
console.log('Checkout opened');
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
window.addEventListener('lce:actions.checkout_closed', (event) => {
|
|
306
|
+
console.log('Checkout closed');
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
window.addEventListener('lce:actions.checkout_failed', (event) => {
|
|
310
|
+
console.error('Checkout failed:', event.detail.data.error);
|
|
311
|
+
});
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Customer Information
|
|
315
|
+
|
|
316
|
+
```javascript
|
|
317
|
+
window.addEventListener('lce:actions.checkout_customer_information_updated', (event) => {
|
|
318
|
+
const { email, phone } = event.detail.data;
|
|
319
|
+
console.log('Customer info updated:', email);
|
|
320
|
+
});
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Gift Information
|
|
324
|
+
|
|
325
|
+
```javascript
|
|
326
|
+
window.addEventListener('lce:actions.checkout_is_gift_toggled', (event) => {
|
|
327
|
+
const { isGift } = event.detail.data;
|
|
328
|
+
console.log('Gift mode:', isGift ? 'enabled' : 'disabled');
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
window.addEventListener('lce:actions.checkout_gift_information_updated', (event) => {
|
|
332
|
+
console.log('Gift recipient updated');
|
|
333
|
+
});
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Billing Information
|
|
337
|
+
|
|
338
|
+
```javascript
|
|
339
|
+
window.addEventListener('lce:actions.checkout_billing_same_as_shipping_toggled', (event) => {
|
|
340
|
+
const { billingSameAsShipping } = event.detail.data;
|
|
341
|
+
console.log('Billing same as shipping:', billingSameAsShipping);
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
window.addEventListener('lce:actions.checkout_billing_information_updated', (event) => {
|
|
345
|
+
console.log('Billing address updated');
|
|
346
|
+
});
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Marketing Preferences
|
|
350
|
+
|
|
351
|
+
```javascript
|
|
352
|
+
window.addEventListener('lce:actions.checkout_marketing_preferences_toggled', (event) => {
|
|
353
|
+
const { field, active } = event.detail.data;
|
|
354
|
+
console.log(`Marketing ${field}:`, active);
|
|
355
|
+
});
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Items Management
|
|
359
|
+
|
|
360
|
+
```javascript
|
|
361
|
+
window.addEventListener('lce:actions.checkout_item_removed', (event) => {
|
|
362
|
+
const { itemId } = event.detail.data;
|
|
363
|
+
console.log('Item removed:', itemId);
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
window.addEventListener('lce:actions.checkout_item_quantity_increase', (event) => {
|
|
367
|
+
const { itemId, newQuantity } = event.detail.data;
|
|
368
|
+
console.log(`Item ${itemId} quantity: ${newQuantity}`);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
window.addEventListener('lce:actions.checkout_item_quantity_decrease', (event) => {
|
|
372
|
+
const { itemId, newQuantity } = event.detail.data;
|
|
373
|
+
console.log(`Item ${itemId} quantity: ${newQuantity}`);
|
|
374
|
+
});
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### Tips
|
|
378
|
+
|
|
379
|
+
```javascript
|
|
380
|
+
window.addEventListener('lce:actions.checkout_tip_updated', (event) => {
|
|
381
|
+
const { tip } = event.detail.data;
|
|
382
|
+
console.log('Tip amount:', tip / 100);
|
|
383
|
+
});
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Payment & Submission
|
|
387
|
+
|
|
388
|
+
```javascript
|
|
389
|
+
window.addEventListener('lce:actions.checkout_submit_started', (event) => {
|
|
390
|
+
console.log('Processing payment...');
|
|
391
|
+
// Show loading state
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
window.addEventListener('lce:actions.checkout_submit_completed', (event) => {
|
|
395
|
+
const { orderId } = event.detail.data;
|
|
396
|
+
console.log('Order completed:', orderId);
|
|
397
|
+
// Redirect to confirmation page
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
window.addEventListener('lce:actions.checkout_submit_failed', (event) => {
|
|
401
|
+
const { error } = event.detail.data;
|
|
402
|
+
console.error('Payment failed:', error);
|
|
403
|
+
// Show error message
|
|
404
|
+
});
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Promo Codes
|
|
408
|
+
|
|
409
|
+
```javascript
|
|
410
|
+
window.addEventListener('lce:actions.checkout_promo_code_applied', (event) => {
|
|
411
|
+
const { discount, newTotal } = event.detail.data;
|
|
412
|
+
console.log(`Promo applied: $${discount / 100} off`);
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
window.addEventListener('lce:actions.checkout_promo_code_removed', (event) => {
|
|
416
|
+
console.log('Promo code removed');
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
window.addEventListener('lce:actions.checkout_promo_code_failed', (event) => {
|
|
420
|
+
const { error } = event.detail.data;
|
|
421
|
+
console.error('Promo code failed:', error);
|
|
422
|
+
});
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### Gift Cards
|
|
426
|
+
|
|
427
|
+
```javascript
|
|
428
|
+
window.addEventListener('lce:actions.checkout_gift_card_applied', (event) => {
|
|
429
|
+
const { newTotal } = event.detail.data;
|
|
430
|
+
console.log('Gift card applied, new total:', newTotal / 100);
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
window.addEventListener('lce:actions.checkout_gift_card_removed', (event) => {
|
|
434
|
+
console.log('Gift card removed');
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
window.addEventListener('lce:actions.checkout_gift_card_failed', (event) => {
|
|
438
|
+
const { error } = event.detail.data;
|
|
439
|
+
console.error('Gift card failed:', error);
|
|
440
|
+
});
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### Product Add to Checkout
|
|
444
|
+
|
|
445
|
+
```javascript
|
|
446
|
+
window.addEventListener('lce:actions.checkout_product_add_success', (event) => {
|
|
447
|
+
const { itemsAdded, identifiers } = event.detail.data;
|
|
448
|
+
console.log(`Added ${itemsAdded} items to checkout`);
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
window.addEventListener('lce:actions.checkout_product_add_failed', (event) => {
|
|
452
|
+
const { error } = event.detail.data;
|
|
453
|
+
console.error('Failed to add to checkout:', error);
|
|
454
|
+
});
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
## Customization
|
|
458
|
+
|
|
459
|
+
### Theme Configuration
|
|
460
|
+
|
|
461
|
+
```javascript
|
|
462
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
463
|
+
env: 'production',
|
|
464
|
+
customTheme: {
|
|
465
|
+
checkout: {
|
|
466
|
+
theme: {
|
|
467
|
+
backgroundColor: '#ffffff'
|
|
468
|
+
},
|
|
469
|
+
layout: {
|
|
470
|
+
allowGiftCards: true,
|
|
471
|
+
exitUrl: 'https://yoursite.com/shop',
|
|
472
|
+
continueShoppingUrl: 'https://yoursite.com/shop',
|
|
473
|
+
drawerHeaderText: 'Checkout',
|
|
474
|
+
placeOrderButtonText: 'Complete Purchase'
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
## Payment Integration
|
|
482
|
+
|
|
483
|
+
The SDK uses Stripe for payment processing. Payment form is embedded and handles:
|
|
484
|
+
- Credit/debit cards
|
|
485
|
+
- Apple Pay (when available)
|
|
486
|
+
- Google Pay (when available)
|
|
487
|
+
- PCI compliance
|
|
488
|
+
- 3D Secure authentication
|
|
489
|
+
|
|
490
|
+
No additional Stripe integration code needed - it's built-in.
|
|
491
|
+
|
|
492
|
+
## Checkout Flow
|
|
493
|
+
|
|
494
|
+
### Standard Flow
|
|
495
|
+
|
|
496
|
+
1. Customer opens checkout (from cart or direct)
|
|
497
|
+
2. Reviews order summary
|
|
498
|
+
3. Enters shipping information
|
|
499
|
+
4. Enters payment information
|
|
500
|
+
5. Optionally enters billing address
|
|
501
|
+
6. Reviews total (with promo codes, gift cards, tips)
|
|
502
|
+
7. Places order
|
|
503
|
+
8. Sees order confirmation
|
|
504
|
+
|
|
505
|
+
### Gift Flow
|
|
506
|
+
|
|
507
|
+
1. Customer enables "Send as Gift"
|
|
508
|
+
2. Enters their billing/payment information
|
|
509
|
+
3. Enters recipient's shipping information
|
|
510
|
+
4. Adds gift message (optional)
|
|
511
|
+
5. Places order
|
|
512
|
+
6. Confirmation shows gift delivery details
|
|
513
|
+
|
|
514
|
+
## Presale Products
|
|
515
|
+
|
|
516
|
+
Checkouts with presale items show:
|
|
517
|
+
- Countdown timer for presale expiration
|
|
518
|
+
- Expected delivery date
|
|
519
|
+
- Special handling for presale orders
|
|
520
|
+
|
|
521
|
+
When presale expires:
|
|
522
|
+
- Shows expiration notice
|
|
523
|
+
- Disables checkout submission
|
|
524
|
+
|
|
525
|
+
## Best Practices
|
|
526
|
+
|
|
527
|
+
### Pre-fill Known Information
|
|
528
|
+
|
|
529
|
+
If you have customer data, pre-fill it:
|
|
530
|
+
|
|
531
|
+
```javascript
|
|
532
|
+
// After user logs in
|
|
533
|
+
if (userIsLoggedIn) {
|
|
534
|
+
window.addEventListener('lce:actions.checkout_opened', () => {
|
|
535
|
+
window.elements.actions.checkout.updateCustomerInfo({
|
|
536
|
+
firstName: currentUser.firstName,
|
|
537
|
+
lastName: currentUser.lastName,
|
|
538
|
+
email: currentUser.email,
|
|
539
|
+
phone: currentUser.phone
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
### Track Conversion Funnel
|
|
546
|
+
|
|
547
|
+
```javascript
|
|
548
|
+
const checkoutFunnel = {
|
|
549
|
+
loaded: false,
|
|
550
|
+
infoEntered: false,
|
|
551
|
+
paymentEntered: false,
|
|
552
|
+
submitted: false
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
window.addEventListener('lce:actions.checkout_loaded', () => {
|
|
556
|
+
checkoutFunnel.loaded = true;
|
|
557
|
+
gtag('event', 'begin_checkout');
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
window.addEventListener('lce:actions.checkout_customer_information_updated', () => {
|
|
561
|
+
if (!checkoutFunnel.infoEntered) {
|
|
562
|
+
checkoutFunnel.infoEntered = true;
|
|
563
|
+
gtag('event', 'checkout_progress', { step: 'customer_info' });
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
window.addEventListener('lce:actions.checkout_submit_completed', (event) => {
|
|
568
|
+
gtag('event', 'purchase', {
|
|
569
|
+
transaction_id: event.detail.data.orderId,
|
|
570
|
+
value: event.detail.data.total / 100,
|
|
571
|
+
currency: 'USD'
|
|
572
|
+
});
|
|
573
|
+
});
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
### Handle Submission States
|
|
577
|
+
|
|
578
|
+
```javascript
|
|
579
|
+
window.addEventListener('lce:actions.checkout_submit_started', () => {
|
|
580
|
+
// Disable navigation
|
|
581
|
+
window.onbeforeunload = () => 'Payment in progress...';
|
|
582
|
+
|
|
583
|
+
// Show loading overlay
|
|
584
|
+
showGlobalLoadingOverlay('Processing your order...');
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
window.addEventListener('lce:actions.checkout_submit_completed', () => {
|
|
588
|
+
// Re-enable navigation
|
|
589
|
+
window.onbeforeunload = null;
|
|
590
|
+
|
|
591
|
+
// Redirect to confirmation
|
|
592
|
+
window.location.href = '/order-confirmation';
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
window.addEventListener('lce:actions.checkout_submit_failed', () => {
|
|
596
|
+
// Re-enable navigation
|
|
597
|
+
window.onbeforeunload = null;
|
|
598
|
+
|
|
599
|
+
// Hide loading
|
|
600
|
+
hideGlobalLoadingOverlay();
|
|
601
|
+
});
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
## Configuration Options
|
|
605
|
+
|
|
606
|
+
### Enable/Disable Features
|
|
607
|
+
|
|
608
|
+
```javascript
|
|
609
|
+
checkout: {
|
|
610
|
+
layout: {
|
|
611
|
+
allowGiftCards: true, // Show gift card input
|
|
612
|
+
emailOptIn: {
|
|
613
|
+
show: true, // Show email opt-in checkbox
|
|
614
|
+
checked: false, // Default unchecked
|
|
615
|
+
text: 'Subscribe to our newsletter'
|
|
616
|
+
},
|
|
617
|
+
smsOptIn: {
|
|
618
|
+
show: false, // Hide SMS opt-in checkbox
|
|
619
|
+
checked: false, // Default unchecked
|
|
620
|
+
text: 'Receive SMS updates'
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
### Button Text
|
|
627
|
+
|
|
628
|
+
```javascript
|
|
629
|
+
checkout: {
|
|
630
|
+
layout: {
|
|
631
|
+
placeOrderButtonText: 'Complete Purchase'
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
## Troubleshooting
|
|
637
|
+
|
|
638
|
+
### Checkout Not Opening
|
|
639
|
+
|
|
640
|
+
1. Verify cart has items: `window.elements.actions.cart.getDetails()`
|
|
641
|
+
2. Check for JavaScript errors in console
|
|
642
|
+
3. Ensure SDK is initialized: `window.elements`
|
|
643
|
+
4. Try manually: `window.elements.actions.checkout.openCheckout()`
|
|
644
|
+
|
|
645
|
+
### Payment Form Not Loading
|
|
646
|
+
|
|
647
|
+
1. Check internet connection (Stripe requires network)
|
|
648
|
+
2. Verify Stripe is not blocked by ad blockers
|
|
649
|
+
3. Check browser console for Stripe errors
|
|
650
|
+
4. Ensure your API key is valid
|
|
651
|
+
|
|
652
|
+
### Customer Info Not Pre-filling
|
|
653
|
+
|
|
654
|
+
1. Verify you're calling `updateCustomerInfo()` after checkout loads
|
|
655
|
+
2. Check field names match exactly (case-sensitive)
|
|
656
|
+
3. Ensure values are strings, not other types
|
|
657
|
+
4. Listen for checkout_opened event before updating
|
|
658
|
+
|
|
659
|
+
### Order Submission Failing
|
|
660
|
+
|
|
661
|
+
1. Check all required fields are filled
|
|
662
|
+
2. Verify payment information is valid
|
|
663
|
+
3. Look for validation errors in UI
|
|
664
|
+
4. Check console for detailed error messages
|
|
665
|
+
5. Ensure products are still available
|
|
666
|
+
|
|
667
|
+
## See Also
|
|
668
|
+
|
|
669
|
+
- [Cart Component](./cart-component.md) - Shopping cart functionality
|
|
670
|
+
- [Actions API](../api/actions/checkout-actions.md) - Checkout actions reference
|
|
671
|
+
- [Events](./events.md) - All available events
|
|
672
|
+
- [Theming](./theming.md) - Customize appearance
|