@liquidcommerce/elements-sdk 2.7.0 → 2.7.1
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 +6877 -6825
- package/dist/index.esm.js +11384 -10940
- 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/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/modules/address/address-input.component.d.ts +11 -0
- 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/docs/gitbook/actions.md +160 -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 +137 -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 +191 -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 +35 -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,191 @@
|
|
|
1
|
+
# Events Guide
|
|
2
|
+
|
|
3
|
+
The SDK publishes events for all user interactions and state changes.
|
|
4
|
+
|
|
5
|
+
## Event Format
|
|
6
|
+
|
|
7
|
+
All SDK events follow this pattern:
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
window.addEventListener('lce:actions.event_name', (event) => {
|
|
11
|
+
const {
|
|
12
|
+
namespace, // 'lce:actions'
|
|
13
|
+
event: eventName, // 'cart_item_added'
|
|
14
|
+
timestamp, // Unix timestamp
|
|
15
|
+
id, // Unique event ID
|
|
16
|
+
data // Event-specific data
|
|
17
|
+
} = event.detail;
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Event Namespaces
|
|
22
|
+
|
|
23
|
+
- `lce:actions.*` - User actions and state changes
|
|
24
|
+
- `lce:forms.*` - Form interactions (checkout)
|
|
25
|
+
|
|
26
|
+
## Core Events
|
|
27
|
+
|
|
28
|
+
### Client Ready
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
window.addEventListener('lce:actions.client_ready', (event) => {
|
|
32
|
+
const { isReady, version, timestamp } = event.detail.data;
|
|
33
|
+
console.log(`Elements SDK v${version} is ready`);
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Product Events
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
// Product loaded
|
|
41
|
+
window.addEventListener('lce:actions.product_loaded', (event) => {
|
|
42
|
+
const { identifier, name, price } = event.detail.data;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Add to cart clicked
|
|
46
|
+
window.addEventListener('lce:actions.product_add_to_cart', (event) => {
|
|
47
|
+
const { identifier, quantity, fulfillmentType } = event.detail.data;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Size changed
|
|
51
|
+
window.addEventListener('lce:actions.product_size_changed', (event) => {
|
|
52
|
+
const { identifier, selectedSize } = event.detail.data;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Fulfillment type changed
|
|
56
|
+
window.addEventListener('lce:actions.product_fulfillment_type_changed', (event) => {
|
|
57
|
+
const { identifier, fulfillmentType } = event.detail.data;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Retailer changed
|
|
61
|
+
window.addEventListener('lce:actions.product_fulfillment_changed', (event) => {
|
|
62
|
+
const { identifier, selectedRetailer } = event.detail.data;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Quantity changed
|
|
66
|
+
window.addEventListener('lce:actions.product_quantity_increase', (event) => {});
|
|
67
|
+
window.addEventListener('lce:actions.product_quantity_decrease', (event) => {});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Address Events
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
// Address set
|
|
74
|
+
window.addEventListener('lce:actions.address_updated', (event) => {
|
|
75
|
+
const { address, coordinates, formattedAddress } = event.detail.data;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Address cleared
|
|
79
|
+
window.addEventListener('lce:actions.address_cleared', (event) => {});
|
|
80
|
+
|
|
81
|
+
// Address error
|
|
82
|
+
window.addEventListener('lce:actions.address_failed', (event) => {
|
|
83
|
+
const { error } = event.detail.data;
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Cart Events
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
// Cart loaded
|
|
91
|
+
window.addEventListener('lce:actions.cart_loaded', (event) => {
|
|
92
|
+
const { cartId, itemsCount } = event.detail.data;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Cart opened/closed
|
|
96
|
+
window.addEventListener('lce:actions.cart_opened', (event) => {});
|
|
97
|
+
window.addEventListener('lce:actions.cart_closed', (event) => {});
|
|
98
|
+
|
|
99
|
+
// Cart updated
|
|
100
|
+
window.addEventListener('lce:actions.cart_updated', (event) => {
|
|
101
|
+
const { cartId, itemsCount, subtotal } = event.detail.data;
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Item added/removed
|
|
105
|
+
window.addEventListener('lce:actions.cart_item_added', (event) => {});
|
|
106
|
+
window.addEventListener('lce:actions.cart_item_removed', (event) => {});
|
|
107
|
+
|
|
108
|
+
// Quantity changed
|
|
109
|
+
window.addEventListener('lce:actions.cart_item_quantity_increase', (event) => {});
|
|
110
|
+
window.addEventListener('lce:actions.cart_item_quantity_decrease', (event) => {});
|
|
111
|
+
|
|
112
|
+
// Promo code events
|
|
113
|
+
window.addEventListener('lce:actions.cart_promo_code_applied', (event) => {
|
|
114
|
+
const { discount, newSubtotal } = event.detail.data;
|
|
115
|
+
});
|
|
116
|
+
window.addEventListener('lce:actions.cart_promo_code_removed', (event) => {});
|
|
117
|
+
window.addEventListener('lce:actions.cart_promo_code_failed', (event) => {});
|
|
118
|
+
|
|
119
|
+
// Product add success/failure
|
|
120
|
+
window.addEventListener('lce:actions.cart_product_add_success', (event) => {
|
|
121
|
+
const { itemsAdded, identifiers } = event.detail.data;
|
|
122
|
+
});
|
|
123
|
+
window.addEventListener('lce:actions.cart_product_add_failed', (event) => {
|
|
124
|
+
const { error } = event.detail.data;
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Checkout Events
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
// Lifecycle
|
|
132
|
+
window.addEventListener('lce:actions.checkout_loaded', (event) => {});
|
|
133
|
+
window.addEventListener('lce:actions.checkout_opened', (event) => {});
|
|
134
|
+
window.addEventListener('lce:actions.checkout_closed', (event) => {});
|
|
135
|
+
|
|
136
|
+
// Form updates
|
|
137
|
+
window.addEventListener('lce:actions.checkout_customer_information_updated', (event) => {});
|
|
138
|
+
window.addEventListener('lce:actions.checkout_billing_information_updated', (event) => {});
|
|
139
|
+
window.addEventListener('lce:actions.checkout_gift_information_updated', (event) => {});
|
|
140
|
+
|
|
141
|
+
// Toggles
|
|
142
|
+
window.addEventListener('lce:actions.checkout_is_gift_toggled', (event) => {
|
|
143
|
+
const { isGift } = event.detail.data;
|
|
144
|
+
});
|
|
145
|
+
window.addEventListener('lce:actions.checkout_billing_same_as_shipping_toggled', (event) => {});
|
|
146
|
+
window.addEventListener('lce:actions.checkout_marketing_preferences_toggled', (event) => {});
|
|
147
|
+
|
|
148
|
+
// Submission
|
|
149
|
+
window.addEventListener('lce:actions.checkout_submit_started', (event) => {});
|
|
150
|
+
window.addEventListener('lce:actions.checkout_submit_completed', (event) => {
|
|
151
|
+
const { orderId, total } = event.detail.data;
|
|
152
|
+
});
|
|
153
|
+
window.addEventListener('lce:actions.checkout_submit_failed', (event) => {
|
|
154
|
+
const { error } = event.detail.data;
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Promo codes & gift cards
|
|
158
|
+
window.addEventListener('lce:actions.checkout_promo_code_applied', (event) => {});
|
|
159
|
+
window.addEventListener('lce:actions.checkout_gift_card_applied', (event) => {});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Use Cases
|
|
163
|
+
|
|
164
|
+
### Analytics Integration
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
// Track page views
|
|
168
|
+
window.addEventListener('lce:actions.product_loaded', (event) => {
|
|
169
|
+
gtag('event', 'view_item', {
|
|
170
|
+
items: [{
|
|
171
|
+
item_id: event.detail.data.identifier,
|
|
172
|
+
item_name: event.detail.data.name,
|
|
173
|
+
price: event.detail.data.price / 100
|
|
174
|
+
}]
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Track purchases
|
|
179
|
+
window.addEventListener('lce:actions.checkout_submit_completed', (event) => {
|
|
180
|
+
gtag('event', 'purchase', {
|
|
181
|
+
transaction_id: event.detail.data.orderId,
|
|
182
|
+
value: event.detail.data.total / 100,
|
|
183
|
+
currency: 'USD'
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## See Also
|
|
189
|
+
|
|
190
|
+
- [Component Guides](../guides/)
|
|
191
|
+
- [Actions API](../api/actions/)
|