@liquidcommerce/elements-sdk 2.6.0-beta.40 → 2.6.0-beta.42
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 +79 -171
- package/dist/index.checkout.esm.js +6814 -6806
- package/dist/index.esm.js +10596 -10567
- package/dist/types/auto-initialize/shared-utils.d.ts +5 -0
- 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/interfaces/core.interface.d.ts +5 -4
- package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
- 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 -320
- package/docs/address.md +0 -242
- package/docs/browser-support.md +0 -279
- package/docs/cart.md +0 -387
- package/docs/checkout.md +0 -420
- package/docs/configuration.md +0 -1017
- package/docs/events.md +0 -181
- package/docs/product-list.md +0 -311
- package/docs/product.md +0 -250
- package/docs/proxy.md +0 -228
- package/docs/theming.md +0 -682
- package/docs/troubleshooting.md +0 -793
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Error Handling
|
|
2
|
+
|
|
3
|
+
The SDK emits errors as events and (when applicable) throws a custom `SDKError`. Your app should handle both.
|
|
4
|
+
|
|
5
|
+
## SDKError
|
|
6
|
+
|
|
7
|
+
All SDK errors use a custom error class:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
class SDKError extends Error {
|
|
11
|
+
constructor(message: string, reThrow?: boolean);
|
|
12
|
+
name: 'SDKError';
|
|
13
|
+
isSdk: boolean;
|
|
14
|
+
reThrow: boolean;
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Catching Errors
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
try {
|
|
22
|
+
await window.elements.injectProductElement([
|
|
23
|
+
{ containerId: 'product', identifier: 'invalid_id' }
|
|
24
|
+
]);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (error.name === 'SDKError') {
|
|
27
|
+
console.error('SDK Error:', error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Error Isolation
|
|
33
|
+
|
|
34
|
+
The SDK catches and contains its own errors so your app keeps running:
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
window.elements.actions.cart.addProduct([/* invalid */]);
|
|
38
|
+
console.log('App still working');
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Error Events
|
|
42
|
+
|
|
43
|
+
Listen for failure events to show user-friendly messages or trigger retries:
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
// Cart add failed
|
|
47
|
+
window.addEventListener('lce:actions.cart_product_add_failed', (event) => {
|
|
48
|
+
console.error('Failed to add:', event.detail.data.error);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Address failed
|
|
52
|
+
window.addEventListener('lce:actions.address_failed', (event) => {
|
|
53
|
+
console.error('Address error:', event.detail.data.error);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Checkout submit failed
|
|
57
|
+
window.addEventListener('lce:actions.checkout_submit_failed', (event) => {
|
|
58
|
+
console.error('Checkout failed:', event.detail.data.error);
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## UI Errors
|
|
63
|
+
|
|
64
|
+
When a component fails to load, the SDK renders an error view inside the container and logs details to the console.
|
|
65
|
+
|
|
66
|
+
## Related Docs
|
|
67
|
+
|
|
68
|
+
- [Events Guide](../guides/events.md)
|
|
69
|
+
- [Client API](../api/client.md)
|
|
70
|
+
- [Troubleshooting](./troubleshooting.md)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Performance Guide
|
|
2
|
+
|
|
3
|
+
The SDK is optimized out of the box. These tweaks help reduce load time and layout shift.
|
|
4
|
+
|
|
5
|
+
## 1) Load Non-Blocking
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<script defer data-liquid-commerce-elements ...></script>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 2) Use the Checkout-Only Build When Appropriate
|
|
12
|
+
|
|
13
|
+
If you only need checkout, use the tree-shaken build:
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import { ElementsCheckout } from '@liquidcommerce/elements-sdk/checkout';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 3) Inject Components When Needed
|
|
20
|
+
|
|
21
|
+
Inject above-the-fold products first, then load the rest:
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
await client.injectProductElement([
|
|
25
|
+
{ containerId: 'hero-product', identifier: '001' }
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
setTimeout(async () => {
|
|
29
|
+
await client.injectProductElement([
|
|
30
|
+
{ containerId: 'related-1', identifier: '002' },
|
|
31
|
+
{ containerId: 'related-2', identifier: '003' }
|
|
32
|
+
]);
|
|
33
|
+
}, 1000);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 4) Reserve Space to Prevent Layout Shift
|
|
37
|
+
|
|
38
|
+
```css
|
|
39
|
+
#product {
|
|
40
|
+
min-height: 600px;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 5) Let the SDK Handle Media Optimization
|
|
45
|
+
|
|
46
|
+
The SDK automatically:
|
|
47
|
+
- Lazy loads images
|
|
48
|
+
- Uses responsive image sizes
|
|
49
|
+
- Virtualizes carousel images
|
|
50
|
+
|
|
51
|
+
## Related Docs
|
|
52
|
+
|
|
53
|
+
- [Best Practices](../guides/best-practices.md)
|
|
54
|
+
- [Product Component](../guides/product-component.md)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
Common setup issues and how to resolve them.
|
|
4
|
+
|
|
5
|
+
## SDK Script Not Loading
|
|
6
|
+
|
|
7
|
+
**Symptoms:** 404/CORS in Network tab, `window.elements` is undefined.
|
|
8
|
+
|
|
9
|
+
**Fixes:**
|
|
10
|
+
- Verify the script URL and that the tag includes `data-liquid-commerce-elements`.
|
|
11
|
+
- Check ad blockers; proxy the API if needed.
|
|
12
|
+
- Confirm `data-env` is set correctly.
|
|
13
|
+
|
|
14
|
+
## Web Components Error
|
|
15
|
+
|
|
16
|
+
**Symptoms:** Console logs about Custom Elements or Shadow DOM.
|
|
17
|
+
|
|
18
|
+
**Fix:** Add the Web Components polyfill before the SDK:
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-bundle.js"></script>
|
|
22
|
+
<script defer data-liquid-commerce-elements ...></script>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Product Not Showing
|
|
26
|
+
|
|
27
|
+
**Symptoms:** Empty container or error view.
|
|
28
|
+
|
|
29
|
+
**Fixes:**
|
|
30
|
+
- Confirm the container ID matches your HTML.
|
|
31
|
+
- Verify the product identifier exists.
|
|
32
|
+
- Check for errors in the console or network tab.
|
|
33
|
+
|
|
34
|
+
## Cart Drawer Not Opening
|
|
35
|
+
|
|
36
|
+
**Symptoms:** Add to cart works but cart stays closed.
|
|
37
|
+
|
|
38
|
+
**Fixes:**
|
|
39
|
+
- Ensure a cart button is configured or call `window.elements.actions.cart.openCart()`.
|
|
40
|
+
- Check for JavaScript errors in the console.
|
|
41
|
+
|
|
42
|
+
## Checkout Issues
|
|
43
|
+
|
|
44
|
+
**Symptoms:** Checkout fails to load or submit.
|
|
45
|
+
|
|
46
|
+
**Fixes:**
|
|
47
|
+
- Verify you are on a supported browser.
|
|
48
|
+
- Look for `checkout_*_failed` events in the console.
|
|
49
|
+
- Check for Stripe-related errors in the browser console.
|
|
50
|
+
|
|
51
|
+
## Address/Availability Problems
|
|
52
|
+
|
|
53
|
+
**Symptoms:** Products show unavailable or address prompts fail.
|
|
54
|
+
|
|
55
|
+
**Fixes:**
|
|
56
|
+
- Make sure the address is set and valid.
|
|
57
|
+
- Listen for `lce:actions.address_failed` to surface errors.
|
|
58
|
+
|
|
59
|
+
## Related Docs
|
|
60
|
+
|
|
61
|
+
- [Installation](../getting-started/installation.md)
|
|
62
|
+
- [Browser Support](./browser-support.md)
|
|
63
|
+
- [Error Handling](./error-handling.md)
|
|
64
|
+
- [Proxy Setup](../integration/proxy-setup.md)
|
package/package.json
CHANGED
package/docs/actions.md
DELETED
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
# Actions
|
|
2
|
-
|
|
3
|
-
Actions let you control the SDK with JavaScript instead of (or in addition to) user interactions. Open the cart when a user clicks your custom button, pre-fill checkout forms for returning customers, or add products to cart from anywhere in your app.
|
|
4
|
-
|
|
5
|
-
## Accessing Actions
|
|
6
|
-
|
|
7
|
-
```javascript
|
|
8
|
-
// Global access
|
|
9
|
-
const { actions } = window.elements;
|
|
10
|
-
|
|
11
|
-
// Or from client instance
|
|
12
|
-
const client = await Elements('YOUR_API_KEY', config);
|
|
13
|
-
// Access via client.actions
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## How Actions Work
|
|
17
|
-
|
|
18
|
-
Actions are fire-and-forget methods that return `void` or `Promise<void>`. All feedback comes through [events](./events.md) - this is by design for security.
|
|
19
|
-
|
|
20
|
-
```javascript
|
|
21
|
-
// 1. Listen for feedback
|
|
22
|
-
window.addEventListener('lce:actions.cart_promo_code_applied', (event) => {
|
|
23
|
-
const { discount, newSubtotal } = event.detail.data;
|
|
24
|
-
showSuccess(`Saved $${discount}!`);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// 2. Fire the action
|
|
28
|
-
await actions.cart.applyPromoCode('SUMMER20');
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Address Actions
|
|
34
|
-
|
|
35
|
-
Manage the customer's delivery location.
|
|
36
|
-
|
|
37
|
-
| Method | Returns | Description |
|
|
38
|
-
|--------|---------|-------------|
|
|
39
|
-
| `setAddressByPlacesId(placesId)` | `Promise<void>` | Set location via Google Places ID |
|
|
40
|
-
| `setAddressManually(address, coords)` | `Promise<void>` | Set location with address and coordinates |
|
|
41
|
-
| `getDetails()` | `IAddressData \| null` | Get current address |
|
|
42
|
-
| `clear()` | `Promise<void>` | Clear address (also resets cart) |
|
|
43
|
-
|
|
44
|
-
### setAddressByPlacesId
|
|
45
|
-
|
|
46
|
-
```javascript
|
|
47
|
-
await actions.address.setAddressByPlacesId('ChIJN1t_tDeuEmsRUsoyG83frY4');
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### setAddressManually
|
|
51
|
-
|
|
52
|
-
```javascript
|
|
53
|
-
await actions.address.setAddressManually(
|
|
54
|
-
{
|
|
55
|
-
one: '123 Main St',
|
|
56
|
-
two: 'Apt 4B', // optional
|
|
57
|
-
city: 'New York',
|
|
58
|
-
state: 'NY',
|
|
59
|
-
zip: '10001',
|
|
60
|
-
country: 'US' // optional
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
lat: 40.7128,
|
|
64
|
-
long: -74.0060
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### getDetails
|
|
70
|
-
|
|
71
|
-
```javascript
|
|
72
|
-
const address = actions.address.getDetails();
|
|
73
|
-
if (address) {
|
|
74
|
-
console.log(address.formattedAddress);
|
|
75
|
-
console.log(address.coordinates);
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### clear
|
|
80
|
-
|
|
81
|
-
```javascript
|
|
82
|
-
await actions.address.clear();
|
|
83
|
-
// Note: This also clears the cart
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
**Feedback Events:** `address_updated`, `address_cleared`, `address_failed`
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
## Product Actions
|
|
91
|
-
|
|
92
|
-
Query product information.
|
|
93
|
-
|
|
94
|
-
| Method | Returns | Description |
|
|
95
|
-
|--------|---------|-------------|
|
|
96
|
-
| `getDetails(identifier)` | `IBaseProductEventData` | Get product state |
|
|
97
|
-
|
|
98
|
-
### getDetails
|
|
99
|
-
|
|
100
|
-
```javascript
|
|
101
|
-
const product = actions.product.getDetails('00619947000020');
|
|
102
|
-
|
|
103
|
-
console.log(product.name);
|
|
104
|
-
console.log(product.selectedSizeId);
|
|
105
|
-
console.log(product.selectedFulfillmentType);
|
|
106
|
-
console.log(product.priceInfo);
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## Cart Actions
|
|
112
|
-
|
|
113
|
-
Control the shopping cart.
|
|
114
|
-
|
|
115
|
-
| Method | Returns | Description |
|
|
116
|
-
|--------|---------|---------------------|
|
|
117
|
-
| `openCart()` | `void` | Show cart drawer |
|
|
118
|
-
| `closeCart()` | `void` | Hide cart drawer |
|
|
119
|
-
| `toggleCart()` | `void` | Toggle cart drawer |
|
|
120
|
-
| `addProduct(items[], openCart?)` | `Promise<void>` | Add items to cart |
|
|
121
|
-
| `applyPromoCode(code)` | `Promise<void>` | Apply discount code |
|
|
122
|
-
| `removePromoCode()` | `Promise<void>` | Remove discount |
|
|
123
|
-
| `resetCart()` | `Promise<void>` | Clear all items |
|
|
124
|
-
| `getDetails()` | `IBaseCartEventData` | Get cart state |
|
|
125
|
-
|
|
126
|
-
### openCart / closeCart / toggleCart
|
|
127
|
-
|
|
128
|
-
```javascript
|
|
129
|
-
actions.cart.openCart();
|
|
130
|
-
actions.cart.closeCart();
|
|
131
|
-
actions.cart.toggleCart();
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### addProduct
|
|
135
|
-
|
|
136
|
-
```javascript
|
|
137
|
-
await actions.cart.addProduct(
|
|
138
|
-
[
|
|
139
|
-
{
|
|
140
|
-
identifier: '00619947000020',
|
|
141
|
-
fulfillmentType: 'shipping', // 'shipping' or 'onDemand'
|
|
142
|
-
quantity: 2
|
|
143
|
-
}
|
|
144
|
-
],
|
|
145
|
-
true // Open cart after adding (optional)
|
|
146
|
-
);
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### applyPromoCode / removePromoCode
|
|
150
|
-
|
|
151
|
-
```javascript
|
|
152
|
-
await actions.cart.applyPromoCode('SUMMER20');
|
|
153
|
-
await actions.cart.removePromoCode();
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### resetCart
|
|
157
|
-
|
|
158
|
-
```javascript
|
|
159
|
-
await actions.cart.resetCart();
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### getDetails
|
|
163
|
-
|
|
164
|
-
```javascript
|
|
165
|
-
const cart = actions.cart.getDetails();
|
|
166
|
-
|
|
167
|
-
console.log(cart.itemCount);
|
|
168
|
-
console.log(cart.subtotal);
|
|
169
|
-
console.log(cart.items);
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
**Feedback Events:** `cart_opened`, `cart_closed`, `cart_product_add_success`, `cart_product_add_failed`, `cart_promo_code_applied`, `cart_promo_code_removed`, `cart_promo_code_failed`, `cart_reset`
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
## Checkout Actions
|
|
177
|
-
|
|
178
|
-
Control the checkout flow.
|
|
179
|
-
|
|
180
|
-
| Method | Returns | Description |
|
|
181
|
-
|--------|---------|-------------|
|
|
182
|
-
| `openCheckout()` | `void` | Show checkout drawer |
|
|
183
|
-
| `closeCheckout()` | `void` | Hide checkout drawer |
|
|
184
|
-
| `toggleCheckout()` | `void` | Toggle checkout drawer |
|
|
185
|
-
| `exitCheckout()` | `void` | Navigate to exit URL |
|
|
186
|
-
| `addProduct(items[], open?)` | `Promise<void>` | Add to checkout directly |
|
|
187
|
-
| `applyPromoCode(code)` | `Promise<void>` | Apply discount |
|
|
188
|
-
| `removePromoCode()` | `Promise<void>` | Remove discount |
|
|
189
|
-
| `applyGiftCard(code)` | `Promise<void>` | Apply gift card |
|
|
190
|
-
| `removeGiftCard(code)` | `Promise<void>` | Remove gift card |
|
|
191
|
-
| `toggleIsGift(active?)` | `Promise<void>` | Enable/disable gift mode |
|
|
192
|
-
| `toggleBillingSameAsShipping(active?)` | `Promise<void>` | Use same address |
|
|
193
|
-
| `toggleMarketingPreferences(field, active)` | `Promise<void>` | Set opt-in |
|
|
194
|
-
| `updateCustomerInfo(params)` | `void` | Pre-fill customer form |
|
|
195
|
-
| `updateBillingInfo(params)` | `void` | Pre-fill billing form |
|
|
196
|
-
| `updateGiftInfo(params)` | `void` | Pre-fill gift form |
|
|
197
|
-
| `getDetails()` | `ICheckoutDetailsEventData` | Get checkout state |
|
|
198
|
-
|
|
199
|
-
### openCheckout / closeCheckout / toggleCheckout / exitCheckout
|
|
200
|
-
|
|
201
|
-
```javascript
|
|
202
|
-
actions.checkout.openCheckout();
|
|
203
|
-
actions.checkout.closeCheckout();
|
|
204
|
-
actions.checkout.toggleCheckout();
|
|
205
|
-
actions.checkout.exitCheckout(); // Navigates to configured exit URL
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
### addProduct
|
|
209
|
-
|
|
210
|
-
```javascript
|
|
211
|
-
// Add products directly to checkout (skip cart)
|
|
212
|
-
await actions.checkout.addProduct(
|
|
213
|
-
[{ identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }],
|
|
214
|
-
true // Open checkout (optional)
|
|
215
|
-
);
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
### applyPromoCode / removePromoCode
|
|
219
|
-
|
|
220
|
-
```javascript
|
|
221
|
-
await actions.checkout.applyPromoCode('SAVE10');
|
|
222
|
-
await actions.checkout.removePromoCode();
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### applyGiftCard / removeGiftCard
|
|
226
|
-
|
|
227
|
-
```javascript
|
|
228
|
-
await actions.checkout.applyGiftCard('GIFT-XXXX-XXXX');
|
|
229
|
-
await actions.checkout.removeGiftCard('GIFT-XXXX-XXXX');
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### toggleIsGift / toggleBillingSameAsShipping / toggleMarketingPreferences
|
|
233
|
-
|
|
234
|
-
```javascript
|
|
235
|
-
await actions.checkout.toggleIsGift(true);
|
|
236
|
-
await actions.checkout.toggleBillingSameAsShipping(true);
|
|
237
|
-
await actions.checkout.toggleMarketingPreferences('canEmail', true);
|
|
238
|
-
await actions.checkout.toggleMarketingPreferences('canSms', false);
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### updateCustomerInfo
|
|
242
|
-
|
|
243
|
-
```javascript
|
|
244
|
-
actions.checkout.updateCustomerInfo({
|
|
245
|
-
firstName: 'John',
|
|
246
|
-
lastName: 'Doe',
|
|
247
|
-
email: 'john@example.com',
|
|
248
|
-
phone: '555-123-4567'
|
|
249
|
-
});
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
### updateBillingInfo
|
|
253
|
-
|
|
254
|
-
```javascript
|
|
255
|
-
actions.checkout.updateBillingInfo({
|
|
256
|
-
firstName: 'John',
|
|
257
|
-
lastName: 'Doe',
|
|
258
|
-
street1: '123 Billing St',
|
|
259
|
-
street2: 'Suite 100', // optional
|
|
260
|
-
city: 'New York',
|
|
261
|
-
state: 'NY',
|
|
262
|
-
zipCode: '10001'
|
|
263
|
-
});
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
### updateGiftInfo
|
|
267
|
-
|
|
268
|
-
```javascript
|
|
269
|
-
actions.checkout.updateGiftInfo({
|
|
270
|
-
recipientName: 'Jane Smith',
|
|
271
|
-
senderName: 'John Doe',
|
|
272
|
-
giftMessage: 'Happy Birthday!'
|
|
273
|
-
});
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
### getDetails
|
|
277
|
-
|
|
278
|
-
```javascript
|
|
279
|
-
const checkout = actions.checkout.getDetails();
|
|
280
|
-
|
|
281
|
-
console.log(checkout.subtotal);
|
|
282
|
-
console.log(checkout.total);
|
|
283
|
-
console.log(checkout.items);
|
|
284
|
-
console.log(checkout.isGift);
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
**Feedback Events:** `checkout_opened`, `checkout_closed`, `checkout_product_add_success`, `checkout_product_add_failed`, `checkout_promo_code_applied`, `checkout_promo_code_removed`, `checkout_promo_code_failed`, `checkout_gift_card_applied`, `checkout_gift_card_removed`, `checkout_gift_card_failed`
|
|
288
|
-
|
|
289
|
-
---
|
|
290
|
-
|
|
291
|
-
## Product List Actions
|
|
292
|
-
|
|
293
|
-
Coming soon.
|
|
294
|
-
|
|
295
|
-
---
|
|
296
|
-
|
|
297
|
-
## Security Notes
|
|
298
|
-
|
|
299
|
-
Events never expose sensitive information:
|
|
300
|
-
|
|
301
|
-
**Safe in events:**
|
|
302
|
-
- Success/failure status
|
|
303
|
-
- Discount amounts
|
|
304
|
-
- Total amounts
|
|
305
|
-
- Item counts and identifiers
|
|
306
|
-
|
|
307
|
-
**Never exposed:**
|
|
308
|
-
- Promo codes or gift card codes
|
|
309
|
-
- Gift card balances
|
|
310
|
-
- Sensitive financial details
|
|
311
|
-
|
|
312
|
-
---
|
|
313
|
-
|
|
314
|
-
## See Also
|
|
315
|
-
|
|
316
|
-
- [Events Reference](./events.md) - Event feedback for actions
|
|
317
|
-
- [Product](./product.md) - Product component
|
|
318
|
-
- [Cart](./cart.md) - Cart component
|
|
319
|
-
- [Checkout](./checkout.md) - Checkout component
|
|
320
|
-
- [Address](./address.md) - Address component
|