@liquidcommerce/elements-sdk 2.7.2 → 2.7.4
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 +1 -1
- package/dist/index.checkout.esm.js +7345 -7451
- package/dist/index.esm.js +12318 -12512
- package/dist/ssr-stub.checkout.esm.js +18 -0
- package/dist/ssr-stub.esm.js +270 -0
- package/dist/types/auto-initialize/shared-utils.d.ts +3 -1
- package/dist/types/clients/base.d.ts +7 -4
- package/dist/types/clients/builder.d.ts +2 -1
- package/dist/types/clients/checkout.d.ts +2 -10
- package/dist/types/clients/helpers.d.ts +1 -1
- package/dist/types/clients/main.d.ts +2 -1
- package/dist/types/constants/core.constant.d.ts +0 -6
- package/dist/types/core/api/api-client.service.d.ts +16 -15
- package/dist/types/core/api/api-result.d.ts +19 -0
- package/dist/types/core/api/auth-client.service.d.ts +13 -5
- package/dist/types/core/client/client-action.service.d.ts +1 -1
- package/dist/types/core/client/client-config.service.d.ts +1 -1
- package/dist/types/core/pubsub/pubsub.service.d.ts +0 -2
- package/dist/types/core/singleton-manager.service.d.ts +12 -8
- package/dist/types/core/store/interfaces/core.interface.d.ts +8 -12
- package/dist/types/core/store/interfaces/product-list.interface.d.ts +12 -28
- package/dist/types/core/store/store.constant.d.ts +2 -1
- package/dist/types/core/store/store.service.d.ts +1 -0
- package/dist/types/core/telemetry/telemetry.service.d.ts +1 -0
- package/dist/types/enums/core.enum.d.ts +5 -4
- package/dist/types/index.checkout.d.ts +3 -2
- package/dist/types/index.checkout.umd.d.ts +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/interfaces/api/product-list.interface.d.ts +2 -1
- package/dist/types/interfaces/client.interface.d.ts +72 -0
- package/dist/types/interfaces/component.interface.d.ts +7 -0
- package/dist/types/interfaces/config.interface.d.ts +46 -0
- package/dist/types/interfaces/configs/address.interface.d.ts +1 -1
- package/dist/types/interfaces/configs/cart.interface.d.ts +1 -1
- package/dist/types/interfaces/configs/checkout.interface.d.ts +1 -1
- package/dist/types/interfaces/configs/global.interface.d.ts +2 -2
- package/dist/types/interfaces/configs/product-list.interface.d.ts +34 -20
- package/dist/types/interfaces/configs/product.interface.d.ts +1 -1
- package/dist/types/interfaces/injection.interface.d.ts +47 -0
- package/dist/types/modules/address/address-input.component.d.ts +0 -11
- package/dist/types/modules/address/address.command.d.ts +1 -1
- package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +1 -0
- package/dist/types/modules/product/components/product-image-carousel.component.d.ts +3 -0
- package/dist/types/modules/product/components/product-retailers-carousel.component.d.ts +3 -0
- package/dist/types/modules/product/components/product-retailers-popup-list.component.d.ts +5 -2
- package/dist/types/modules/product/product.commands.d.ts +1 -3
- package/dist/types/modules/product-list/components/card-components/index.d.ts +0 -2
- package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +1 -0
- package/dist/types/modules/product-list/components/card-components/product-button.d.ts +1 -3
- package/dist/types/modules/product-list/components/card-components/product-quantity-selector.d.ts +3 -4
- package/dist/types/modules/product-list/components/card-components/product-sizes-list.d.ts +9 -5
- package/dist/types/modules/product-list/components/filter-components/product-list-toggle-filters.d.ts +0 -6
- package/dist/types/modules/product-list/components/index.d.ts +1 -1
- package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +7 -5
- package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +4 -5
- package/dist/types/modules/product-list/components/product-list-product-engraving-lines.component.d.ts +22 -0
- package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +32 -14
- package/dist/types/modules/product-list/components/product-list-search.component.d.ts +4 -3
- package/dist/types/modules/product-list/product-list-card.component.d.ts +20 -16
- package/dist/types/modules/product-list/product-list-filter.utils.d.ts +8 -0
- package/dist/types/modules/product-list/product-list.commands.d.ts +16 -62
- package/dist/types/modules/product-list/product-list.component.d.ts +3 -11
- package/dist/types/modules/product-list/product-list.constants.d.ts +0 -1
- package/dist/types/modules/product-list/product-list.interface.d.ts +0 -30
- package/dist/types/modules/ui-components/drawer/drawer.component.d.ts +1 -0
- package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +2 -10
- package/dist/types/modules/ui-components/engraving/engraving-view.component.d.ts +5 -1
- package/dist/types/modules/ui-components/promo-code-ticker/promo-code-ticker.component.d.ts +1 -1
- package/dist/types/modules/ui-components/ui.commands.d.ts +6 -4
- package/dist/types/ssr/stub.checkout.d.ts +6 -0
- package/dist/types/ssr/stub.d.ts +10 -0
- package/dist/types/utils/product-selection.d.ts +16 -0
- package/dist/types/utils/product.d.ts +10 -0
- package/docs/v1/README.md +2 -2
- package/docs/v1/api/actions/address-actions.md +11 -11
- package/docs/v1/api/actions/cart-actions.md +13 -13
- package/docs/v1/api/actions/checkout-actions.md +23 -23
- package/docs/v1/api/actions/product-actions.md +6 -6
- package/docs/v1/api/client.md +11 -11
- package/docs/v1/api/ui-helpers.md +11 -11
- package/docs/v1/examples/advanced-patterns.md +1 -1
- package/docs/v1/examples/checkout-flow.md +1 -1
- package/docs/v1/getting-started/concepts.md +7 -7
- package/docs/v1/getting-started/installation.md +2 -2
- package/docs/v1/getting-started/quick-start.md +3 -3
- package/docs/v1/guides/address-component.md +11 -11
- package/docs/v1/guides/best-practices.md +14 -14
- package/docs/v1/guides/cart-component.md +23 -23
- package/docs/v1/guides/checkout-component.md +24 -24
- package/docs/v1/guides/product-component.md +5 -5
- package/docs/v1/integration/nextjs.md +11 -2
- package/docs/v1/integration/react.md +3 -3
- package/docs/v1/integration/vanilla-js.md +1 -1
- package/docs/v1/integration/vue.md +24 -0
- package/docs/v1/reference/error-handling.md +2 -2
- package/docs/v1/reference/troubleshooting.md +10 -2
- package/package.json +17 -13
- package/dist/types/interfaces/core.interface.d.ts +0 -140
- package/dist/types/modules/product-list/components/card-components/product-fulfillments.d.ts +0 -12
- package/dist/types/modules/product-list/components/card-components/product-title.d.ts +0 -6
- package/dist/types/modules/product-list/components/product-list-retailers.component.d.ts +0 -26
- package/dist/types/modules/ui-components/modal/modal.component.d.ts +0 -23
- package/dist/types/modules/ui-components/styles/modal.style.d.ts +0 -1
- package/docs/gitbook/actions.md +0 -964
- package/docs/gitbook/address.md +0 -48
- package/docs/gitbook/cart.md +0 -65
- package/docs/gitbook/checkout.md +0 -131
- package/docs/gitbook/events.md +0 -1765
- package/docs/gitbook/overview.md +0 -166
- package/docs/gitbook/product.md +0 -64
- package/docs/gitbook/quick-start-guide.md +0 -393
|
@@ -156,7 +156,7 @@ If you prefer JavaScript over HTML attributes:
|
|
|
156
156
|
<script defer>
|
|
157
157
|
// Wait for SDK to be ready
|
|
158
158
|
window.addEventListener('lce:actions.client_ready', async (event) => {
|
|
159
|
-
const client = window.elements;
|
|
159
|
+
const client = window.LiquidCommerce.elements;
|
|
160
160
|
|
|
161
161
|
// Inject the product
|
|
162
162
|
await client.injectProductElement([
|
|
@@ -252,7 +252,7 @@ Want to customize the look, visit the Elements Builder in our [Partner Portal](h
|
|
|
252
252
|
```html
|
|
253
253
|
<script>
|
|
254
254
|
window.addEventListener('lce:actions.client_ready', async () => {
|
|
255
|
-
const client = window.elements;
|
|
255
|
+
const client = window.LiquidCommerce.elements;
|
|
256
256
|
|
|
257
257
|
// You can customize after initialization
|
|
258
258
|
// See Theming Guide for more options
|
|
@@ -313,7 +313,7 @@ The cart should open automatically after adding a product. If it doesn't:
|
|
|
313
313
|
|
|
314
314
|
1. Check browser console for JavaScript errors
|
|
315
315
|
2. Verify no other scripts are conflicting
|
|
316
|
-
3. Try manually opening: `window.elements.actions.cart.openCart()`
|
|
316
|
+
3. Try manually opening: `window.LiquidCommerce.elements.actions.cart.openCart()`
|
|
317
317
|
|
|
318
318
|
## Next Steps
|
|
319
319
|
|
|
@@ -52,7 +52,7 @@ await client.injectAddressElement('address-container', {
|
|
|
52
52
|
The recommended method - provides accurate geocoding:
|
|
53
53
|
|
|
54
54
|
```javascript
|
|
55
|
-
await window.elements.actions.address.setAddressByPlacesId('ChIJOwg_06VPwokRYv534QaPC8g');
|
|
55
|
+
await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId('ChIJOwg_06VPwokRYv534QaPC8g');
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
**How to get a Places ID:**
|
|
@@ -64,7 +64,7 @@ Visit [Google Place IDs](https://developers.google.com/maps/documentation/places
|
|
|
64
64
|
For custom address flows without Google Places:
|
|
65
65
|
|
|
66
66
|
```javascript
|
|
67
|
-
await window.elements.actions.address.setAddressManually(
|
|
67
|
+
await window.LiquidCommerce.elements.actions.address.setAddressManually(
|
|
68
68
|
{
|
|
69
69
|
one: '123 Main Street',
|
|
70
70
|
two: 'Apt 4', // Optional
|
|
@@ -93,7 +93,7 @@ await window.elements.actions.address.setAddressManually(
|
|
|
93
93
|
Retrieve the current address:
|
|
94
94
|
|
|
95
95
|
```javascript
|
|
96
|
-
const addressData = window.elements.actions.address.getDetails();
|
|
96
|
+
const addressData = window.LiquidCommerce.elements.actions.address.getDetails();
|
|
97
97
|
|
|
98
98
|
console.log(addressData);
|
|
99
99
|
// {
|
|
@@ -120,7 +120,7 @@ console.log(addressData);
|
|
|
120
120
|
Remove the current address:
|
|
121
121
|
|
|
122
122
|
```javascript
|
|
123
|
-
await window.elements.actions.address.clear();
|
|
123
|
+
await window.LiquidCommerce.elements.actions.address.clear();
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
This will:
|
|
@@ -209,7 +209,7 @@ Create a dedicated page for address selection:
|
|
|
209
209
|
|
|
210
210
|
<script>
|
|
211
211
|
window.addEventListener('lce:actions.client_ready', async () => {
|
|
212
|
-
await window.elements.injectAddressElement('address');
|
|
212
|
+
await window.LiquidCommerce.elements.injectAddressElement('address');
|
|
213
213
|
});
|
|
214
214
|
|
|
215
215
|
window.addEventListener('lce:actions.address_updated', () => {
|
|
@@ -237,7 +237,7 @@ document.getElementById('save-address-btn').addEventListener('click', async () =
|
|
|
237
237
|
const coords = await geocodeAddress(address);
|
|
238
238
|
|
|
239
239
|
try {
|
|
240
|
-
await window.elements.actions.address.setAddressManually(address, coords);
|
|
240
|
+
await window.LiquidCommerce.elements.actions.address.setAddressManually(address, coords);
|
|
241
241
|
showSuccessMessage('Address saved!');
|
|
242
242
|
} catch (error) {
|
|
243
243
|
showErrorMessage('Invalid address');
|
|
@@ -251,7 +251,7 @@ document.getElementById('save-address-btn').addEventListener('click', async () =
|
|
|
251
251
|
// After user logs in, set their saved address
|
|
252
252
|
window.addEventListener('lce:actions.client_ready', async () => {
|
|
253
253
|
if (userIsLoggedIn && !currentAddressSet) {
|
|
254
|
-
await window.elements.actions.address.setAddressManually(
|
|
254
|
+
await window.LiquidCommerce.elements.actions.address.setAddressManually(
|
|
255
255
|
user.savedAddress,
|
|
256
256
|
user.savedCoordinates
|
|
257
257
|
);
|
|
@@ -288,7 +288,7 @@ const locations = [
|
|
|
288
288
|
document.getElementById('location-select').addEventListener('change', async (e) => {
|
|
289
289
|
const selectedLocation = locations[e.target.value];
|
|
290
290
|
|
|
291
|
-
await window.elements.actions.address.setAddressByPlacesId(
|
|
291
|
+
await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId(
|
|
292
292
|
selectedLocation.placesId
|
|
293
293
|
);
|
|
294
294
|
|
|
@@ -328,7 +328,7 @@ Set address as early as possible in the user flow:
|
|
|
328
328
|
```javascript
|
|
329
329
|
// On homepage or landing page
|
|
330
330
|
window.addEventListener('lce:actions.client_ready', () => {
|
|
331
|
-
const currentAddress = window.elements.actions.address.getDetails();
|
|
331
|
+
const currentAddress = window.LiquidCommerce.elements.actions.address.getDetails();
|
|
332
332
|
|
|
333
333
|
if (!currentAddress) {
|
|
334
334
|
// Show address prompt
|
|
@@ -380,7 +380,7 @@ async function setAddress(address, coords) {
|
|
|
380
380
|
}
|
|
381
381
|
|
|
382
382
|
// Set address
|
|
383
|
-
await window.elements.actions.address.setAddressManually(address, coords);
|
|
383
|
+
await window.LiquidCommerce.elements.actions.address.setAddressManually(address, coords);
|
|
384
384
|
}
|
|
385
385
|
```
|
|
386
386
|
|
|
@@ -388,7 +388,7 @@ async function setAddress(address, coords) {
|
|
|
388
388
|
|
|
389
389
|
```javascript
|
|
390
390
|
try {
|
|
391
|
-
await window.elements.actions.address.setAddressByPlacesId(placesId);
|
|
391
|
+
await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId(placesId);
|
|
392
392
|
} catch (error) {
|
|
393
393
|
console.error('Failed to set address:', error);
|
|
394
394
|
|
|
@@ -21,26 +21,26 @@ await Elements('KEY', { env: 'production' });
|
|
|
21
21
|
|
|
22
22
|
### Use Global Access
|
|
23
23
|
|
|
24
|
-
After initialization, use `window.elements`:
|
|
24
|
+
After initialization, use `window.LiquidCommerce.elements`:
|
|
25
25
|
|
|
26
26
|
```javascript
|
|
27
27
|
// Initialize once
|
|
28
28
|
await Elements('KEY', { env: 'production' });
|
|
29
29
|
|
|
30
30
|
// Use globally throughout your app
|
|
31
|
-
window.elements.actions.cart.openCart();
|
|
31
|
+
window.LiquidCommerce.elements.actions.cart.openCart();
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
### Wait for Client Ready
|
|
35
35
|
|
|
36
36
|
```javascript
|
|
37
|
-
if (window.elements) {
|
|
37
|
+
if (window.LiquidCommerce.elements) {
|
|
38
38
|
// Client already ready
|
|
39
|
-
window.elements.actions.cart.openCart();
|
|
39
|
+
window.LiquidCommerce.elements.actions.cart.openCart();
|
|
40
40
|
} else {
|
|
41
41
|
// Wait for initialization
|
|
42
42
|
window.addEventListener('lce:actions.client_ready', () => {
|
|
43
|
-
window.elements.actions.cart.openCart();
|
|
43
|
+
window.LiquidCommerce.elements.actions.cart.openCart();
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
```
|
|
@@ -83,7 +83,7 @@ await client.injectProductElement([...]);
|
|
|
83
83
|
|
|
84
84
|
```javascript
|
|
85
85
|
try {
|
|
86
|
-
await window.elements.actions.cart.addProduct([...]);
|
|
86
|
+
await window.LiquidCommerce.elements.actions.cart.addProduct([...]);
|
|
87
87
|
} catch (error) {
|
|
88
88
|
if (error.name === 'SDKError') {
|
|
89
89
|
console.error('SDK Error:', error);
|
|
@@ -158,7 +158,7 @@ setTimeout(async () => {
|
|
|
158
158
|
```javascript
|
|
159
159
|
// Set address if known
|
|
160
160
|
if (userSavedAddress) {
|
|
161
|
-
await window.elements.actions.address.setAddressManually(
|
|
161
|
+
await window.LiquidCommerce.elements.actions.address.setAddressManually(
|
|
162
162
|
userSavedAddress,
|
|
163
163
|
userCoordinates
|
|
164
164
|
);
|
|
@@ -167,7 +167,7 @@ if (userSavedAddress) {
|
|
|
167
167
|
// Pre-fill checkout info
|
|
168
168
|
window.addEventListener('lce:actions.checkout_opened', () => {
|
|
169
169
|
if (userIsLoggedIn) {
|
|
170
|
-
window.elements.actions.checkout.updateCustomerInfo({
|
|
170
|
+
window.LiquidCommerce.elements.actions.checkout.updateCustomerInfo({
|
|
171
171
|
firstName: user.firstName,
|
|
172
172
|
email: user.email
|
|
173
173
|
});
|
|
@@ -183,7 +183,7 @@ Cart persists across sessions - avoid clearing unless intentional:
|
|
|
183
183
|
// Only clear when user explicitly requests
|
|
184
184
|
document.getElementById('clear-cart-btn').addEventListener('click', async () => {
|
|
185
185
|
if (confirm('Clear cart?')) {
|
|
186
|
-
await window.elements.actions.cart.resetCart();
|
|
186
|
+
await window.LiquidCommerce.elements.actions.cart.resetCart();
|
|
187
187
|
}
|
|
188
188
|
});
|
|
189
189
|
```
|
|
@@ -195,7 +195,7 @@ document.getElementById('clear-cart-btn').addEventListener('click', async () =>
|
|
|
195
195
|
```javascript
|
|
196
196
|
// Update UI when cart changes
|
|
197
197
|
window.addEventListener('lce:actions.cart_updated', () => {
|
|
198
|
-
const cart = window.elements.actions.cart.getDetails();
|
|
198
|
+
const cart = window.LiquidCommerce.elements.actions.cart.getDetails();
|
|
199
199
|
updateHeaderCartCount(cart.itemsCount);
|
|
200
200
|
});
|
|
201
201
|
```
|
|
@@ -267,11 +267,11 @@ const client = await Elements('YOUR_API_KEY', {
|
|
|
267
267
|
```javascript
|
|
268
268
|
// Test empty cart
|
|
269
269
|
if (isDevelopment) {
|
|
270
|
-
await window.elements.actions.cart.resetCart();
|
|
270
|
+
await window.LiquidCommerce.elements.actions.cart.resetCart();
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
// Test with specific product
|
|
274
|
-
await window.elements.actions.cart.addProduct([
|
|
274
|
+
await window.LiquidCommerce.elements.actions.cart.addProduct([
|
|
275
275
|
{ identifier: testProductId, fulfillmentType: 'shipping', quantity: 1 }
|
|
276
276
|
]);
|
|
277
277
|
```
|
|
@@ -311,9 +311,9 @@ await window.elements.actions.cart.addProduct([
|
|
|
311
311
|
|
|
312
312
|
```javascript
|
|
313
313
|
if (window.innerWidth < 768) {
|
|
314
|
-
window.elements.ui.floatingCartButton(true);
|
|
314
|
+
window.LiquidCommerce.elements.ui.floatingCartButton(true);
|
|
315
315
|
} else {
|
|
316
|
-
window.elements.ui.cartButton('header-cart', true);
|
|
316
|
+
window.LiquidCommerce.elements.ui.cartButton('header-cart', true);
|
|
317
317
|
}
|
|
318
318
|
```
|
|
319
319
|
|
|
@@ -113,13 +113,13 @@ Create cart buttons using JavaScript:
|
|
|
113
113
|
|
|
114
114
|
```javascript
|
|
115
115
|
// Button in a container
|
|
116
|
-
window.elements.ui.cartButton('my-container', false); // No badge
|
|
116
|
+
window.LiquidCommerce.elements.ui.cartButton('my-container', false); // No badge
|
|
117
117
|
|
|
118
118
|
// Button with item count
|
|
119
|
-
window.elements.ui.cartButton('my-container', true); // With badge
|
|
119
|
+
window.LiquidCommerce.elements.ui.cartButton('my-container', true); // With badge
|
|
120
120
|
|
|
121
121
|
// Floating button
|
|
122
|
-
window.elements.ui.floatingCartButton(true); // With badge
|
|
122
|
+
window.LiquidCommerce.elements.ui.floatingCartButton(true); // With badge
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
### Custom Toggle Buttons
|
|
@@ -139,19 +139,19 @@ The SDK automatically adds click handlers to elements with `data-lce-cart-toggle
|
|
|
139
139
|
### Open Cart
|
|
140
140
|
|
|
141
141
|
```javascript
|
|
142
|
-
window.elements.actions.cart.openCart();
|
|
142
|
+
window.LiquidCommerce.elements.actions.cart.openCart();
|
|
143
143
|
```
|
|
144
144
|
|
|
145
145
|
### Close Cart
|
|
146
146
|
|
|
147
147
|
```javascript
|
|
148
|
-
window.elements.actions.cart.closeCart();
|
|
148
|
+
window.LiquidCommerce.elements.actions.cart.closeCart();
|
|
149
149
|
```
|
|
150
150
|
|
|
151
151
|
### Toggle Cart
|
|
152
152
|
|
|
153
153
|
```javascript
|
|
154
|
-
window.elements.actions.cart.toggleCart();
|
|
154
|
+
window.LiquidCommerce.elements.actions.cart.toggleCart();
|
|
155
155
|
```
|
|
156
156
|
|
|
157
157
|
### Add Product to Cart
|
|
@@ -159,7 +159,7 @@ window.elements.actions.cart.toggleCart();
|
|
|
159
159
|
Add products programmatically:
|
|
160
160
|
|
|
161
161
|
```javascript
|
|
162
|
-
await window.elements.actions.cart.addProduct([
|
|
162
|
+
await window.LiquidCommerce.elements.actions.cart.addProduct([
|
|
163
163
|
{
|
|
164
164
|
identifier: '00619947000020',
|
|
165
165
|
fulfillmentType: 'shipping', // or 'onDemand'
|
|
@@ -182,7 +182,7 @@ await window.elements.actions.cart.addProduct([
|
|
|
182
182
|
### Apply Promo Code
|
|
183
183
|
|
|
184
184
|
```javascript
|
|
185
|
-
await window.elements.actions.cart.applyPromoCode('SUMMER20');
|
|
185
|
+
await window.LiquidCommerce.elements.actions.cart.applyPromoCode('SUMMER20');
|
|
186
186
|
```
|
|
187
187
|
|
|
188
188
|
The SDK automatically:
|
|
@@ -194,7 +194,7 @@ The SDK automatically:
|
|
|
194
194
|
### Remove Promo Code
|
|
195
195
|
|
|
196
196
|
```javascript
|
|
197
|
-
await window.elements.actions.cart.removePromoCode();
|
|
197
|
+
await window.LiquidCommerce.elements.actions.cart.removePromoCode();
|
|
198
198
|
```
|
|
199
199
|
|
|
200
200
|
### Reset Cart
|
|
@@ -202,7 +202,7 @@ await window.elements.actions.cart.removePromoCode();
|
|
|
202
202
|
Clear all items from the cart:
|
|
203
203
|
|
|
204
204
|
```javascript
|
|
205
|
-
await window.elements.actions.cart.resetCart();
|
|
205
|
+
await window.LiquidCommerce.elements.actions.cart.resetCart();
|
|
206
206
|
```
|
|
207
207
|
|
|
208
208
|
### Get Cart Details
|
|
@@ -210,7 +210,7 @@ await window.elements.actions.cart.resetCart();
|
|
|
210
210
|
Retrieve current cart information:
|
|
211
211
|
|
|
212
212
|
```javascript
|
|
213
|
-
const cartData = window.elements.actions.cart.getDetails();
|
|
213
|
+
const cartData = window.LiquidCommerce.elements.actions.cart.getDetails();
|
|
214
214
|
|
|
215
215
|
console.log(cartData);
|
|
216
216
|
// {
|
|
@@ -239,7 +239,7 @@ Show cart subtotal anywhere on your page:
|
|
|
239
239
|
|
|
240
240
|
<script>
|
|
241
241
|
window.addEventListener('lce:actions.client_ready', () => {
|
|
242
|
-
window.elements.ui.cartSubtotal('cart-total');
|
|
242
|
+
window.LiquidCommerce.elements.ui.cartSubtotal('cart-total');
|
|
243
243
|
});
|
|
244
244
|
</script>
|
|
245
245
|
```
|
|
@@ -257,7 +257,7 @@ Show the number of items in the cart:
|
|
|
257
257
|
|
|
258
258
|
<script>
|
|
259
259
|
window.addEventListener('lce:actions.client_ready', () => {
|
|
260
|
-
window.elements.ui.cartItemsCount('items-count', {
|
|
260
|
+
window.LiquidCommerce.elements.ui.cartItemsCount('items-count', {
|
|
261
261
|
hideZero: true // Hide when cart is empty
|
|
262
262
|
});
|
|
263
263
|
});
|
|
@@ -425,7 +425,7 @@ When you update the cart in one tab, all other open tabs automatically sync:
|
|
|
425
425
|
|
|
426
426
|
```javascript
|
|
427
427
|
// Tab 1: Add item
|
|
428
|
-
await window.elements.actions.cart.addProduct([...]);
|
|
428
|
+
await window.LiquidCommerce.elements.actions.cart.addProduct([...]);
|
|
429
429
|
|
|
430
430
|
// Tab 2: Cart automatically updates
|
|
431
431
|
// No additional code needed
|
|
@@ -459,10 +459,10 @@ If no address is set when adding to cart, the SDK:
|
|
|
459
459
|
Set address before adding to cart:
|
|
460
460
|
|
|
461
461
|
```javascript
|
|
462
|
-
await window.elements.actions.address.setAddressByPlacesId('ChIJ...');
|
|
462
|
+
await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId('ChIJ...');
|
|
463
463
|
|
|
464
464
|
// Now add to cart
|
|
465
|
-
await window.elements.actions.cart.addProduct([...]);
|
|
465
|
+
await window.LiquidCommerce.elements.actions.cart.addProduct([...]);
|
|
466
466
|
```
|
|
467
467
|
|
|
468
468
|
## Promo Codes
|
|
@@ -627,8 +627,8 @@ const params = new URLSearchParams(window.location.search);
|
|
|
627
627
|
const campaign = params.get('campaign');
|
|
628
628
|
|
|
629
629
|
if (campaign === 'summer-sale') {
|
|
630
|
-
await window.elements.actions.cart.applyPromoCode('SUMMER20');
|
|
631
|
-
window.elements.actions.cart.openCart();
|
|
630
|
+
await window.LiquidCommerce.elements.actions.cart.applyPromoCode('SUMMER20');
|
|
631
|
+
window.LiquidCommerce.elements.actions.cart.openCart();
|
|
632
632
|
}
|
|
633
633
|
```
|
|
634
634
|
|
|
@@ -658,7 +658,7 @@ Pre-load cart on page load for faster access:
|
|
|
658
658
|
```javascript
|
|
659
659
|
window.addEventListener('lce:actions.client_ready', () => {
|
|
660
660
|
// Cart loads automatically, but you can pre-fetch if needed
|
|
661
|
-
window.elements.actions.cart.getDetails();
|
|
661
|
+
window.LiquidCommerce.elements.actions.cart.getDetails();
|
|
662
662
|
});
|
|
663
663
|
```
|
|
664
664
|
|
|
@@ -673,7 +673,7 @@ async function addToCart(productId) {
|
|
|
673
673
|
button.textContent = 'Adding...';
|
|
674
674
|
|
|
675
675
|
try {
|
|
676
|
-
await window.elements.actions.cart.addProduct([
|
|
676
|
+
await window.LiquidCommerce.elements.actions.cart.addProduct([
|
|
677
677
|
{ identifier: productId, fulfillmentType: 'shipping', quantity: 1 }
|
|
678
678
|
], true);
|
|
679
679
|
|
|
@@ -709,14 +709,14 @@ window.addEventListener('lce:actions.cart_updated', (event) => {
|
|
|
709
709
|
|
|
710
710
|
### Cart Not Opening
|
|
711
711
|
|
|
712
|
-
1. Check that SDK is initialized: `console.log(window.elements)`
|
|
712
|
+
1. Check that SDK is initialized: `console.log(window.LiquidCommerce.elements)`
|
|
713
713
|
2. Verify no JavaScript errors in console
|
|
714
714
|
3. Ensure cart button is properly configured
|
|
715
|
-
4. Try manually: `window.elements.actions.cart.openCart()`
|
|
715
|
+
4. Try manually: `window.LiquidCommerce.elements.actions.cart.openCart()`
|
|
716
716
|
|
|
717
717
|
### Items Not Adding
|
|
718
718
|
|
|
719
|
-
1. Check that address is set: `window.elements.actions.address.getDetails()`
|
|
719
|
+
1. Check that address is set: `window.LiquidCommerce.elements.actions.address.getDetails()`
|
|
720
720
|
2. Verify product identifier is valid
|
|
721
721
|
3. Check fulfillment type is available for the product
|
|
722
722
|
4. Look for errors in browser console
|
|
@@ -90,19 +90,19 @@ The `{token}` placeholder is replaced with the checkout token.
|
|
|
90
90
|
### Open Checkout
|
|
91
91
|
|
|
92
92
|
```javascript
|
|
93
|
-
window.elements.actions.checkout.openCheckout();
|
|
93
|
+
window.LiquidCommerce.elements.actions.checkout.openCheckout();
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
### Close Checkout
|
|
97
97
|
|
|
98
98
|
```javascript
|
|
99
|
-
window.elements.actions.checkout.closeCheckout();
|
|
99
|
+
window.LiquidCommerce.elements.actions.checkout.closeCheckout();
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
### Toggle Checkout
|
|
103
103
|
|
|
104
104
|
```javascript
|
|
105
|
-
window.elements.actions.checkout.toggleCheckout();
|
|
105
|
+
window.LiquidCommerce.elements.actions.checkout.toggleCheckout();
|
|
106
106
|
```
|
|
107
107
|
|
|
108
108
|
### Exit Checkout
|
|
@@ -110,7 +110,7 @@ window.elements.actions.checkout.toggleCheckout();
|
|
|
110
110
|
Navigate away from checkout (requires `exitUrl` configuration):
|
|
111
111
|
|
|
112
112
|
```javascript
|
|
113
|
-
window.elements.actions.checkout.exitCheckout();
|
|
113
|
+
window.LiquidCommerce.elements.actions.checkout.exitCheckout();
|
|
114
114
|
```
|
|
115
115
|
|
|
116
116
|
Configure exit URL:
|
|
@@ -130,7 +130,7 @@ customTheme: {
|
|
|
130
130
|
Skip the cart and go directly to checkout:
|
|
131
131
|
|
|
132
132
|
```javascript
|
|
133
|
-
await window.elements.actions.checkout.addProduct([
|
|
133
|
+
await window.LiquidCommerce.elements.actions.checkout.addProduct([
|
|
134
134
|
{
|
|
135
135
|
identifier: '00619947000020',
|
|
136
136
|
fulfillmentType: 'shipping',
|
|
@@ -142,25 +142,25 @@ await window.elements.actions.checkout.addProduct([
|
|
|
142
142
|
### Apply Promo Code
|
|
143
143
|
|
|
144
144
|
```javascript
|
|
145
|
-
await window.elements.actions.checkout.applyPromoCode('WELCOME10');
|
|
145
|
+
await window.LiquidCommerce.elements.actions.checkout.applyPromoCode('WELCOME10');
|
|
146
146
|
```
|
|
147
147
|
|
|
148
148
|
### Remove Promo Code
|
|
149
149
|
|
|
150
150
|
```javascript
|
|
151
|
-
await window.elements.actions.checkout.removePromoCode();
|
|
151
|
+
await window.LiquidCommerce.elements.actions.checkout.removePromoCode();
|
|
152
152
|
```
|
|
153
153
|
|
|
154
154
|
### Apply Gift Card
|
|
155
155
|
|
|
156
156
|
```javascript
|
|
157
|
-
await window.elements.actions.checkout.applyGiftCard('GIFT-1234-5678');
|
|
157
|
+
await window.LiquidCommerce.elements.actions.checkout.applyGiftCard('GIFT-1234-5678');
|
|
158
158
|
```
|
|
159
159
|
|
|
160
160
|
### Remove Gift Card
|
|
161
161
|
|
|
162
162
|
```javascript
|
|
163
|
-
await window.elements.actions.checkout.removeGiftCard('GIFT-1234-5678');
|
|
163
|
+
await window.LiquidCommerce.elements.actions.checkout.removeGiftCard('GIFT-1234-5678');
|
|
164
164
|
```
|
|
165
165
|
|
|
166
166
|
### Toggle Gift Mode
|
|
@@ -169,33 +169,33 @@ Enable/disable "Send as Gift" mode:
|
|
|
169
169
|
|
|
170
170
|
```javascript
|
|
171
171
|
// Enable gift mode
|
|
172
|
-
await window.elements.actions.checkout.toggleIsGift(true);
|
|
172
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleIsGift(true);
|
|
173
173
|
|
|
174
174
|
// Disable gift mode
|
|
175
|
-
await window.elements.actions.checkout.toggleIsGift(false);
|
|
175
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleIsGift(false);
|
|
176
176
|
|
|
177
177
|
// Toggle current state
|
|
178
|
-
await window.elements.actions.checkout.toggleIsGift();
|
|
178
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleIsGift();
|
|
179
179
|
```
|
|
180
180
|
|
|
181
181
|
### Toggle Billing Same As Shipping
|
|
182
182
|
|
|
183
183
|
```javascript
|
|
184
184
|
// Use shipping address for billing
|
|
185
|
-
await window.elements.actions.checkout.toggleBillingSameAsShipping(true);
|
|
185
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleBillingSameAsShipping(true);
|
|
186
186
|
|
|
187
187
|
// Use different billing address
|
|
188
|
-
await window.elements.actions.checkout.toggleBillingSameAsShipping(false);
|
|
188
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleBillingSameAsShipping(false);
|
|
189
189
|
```
|
|
190
190
|
|
|
191
191
|
### Toggle Marketing Preferences
|
|
192
192
|
|
|
193
193
|
```javascript
|
|
194
194
|
// Opt into email marketing
|
|
195
|
-
await window.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
|
|
195
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
|
|
196
196
|
|
|
197
197
|
// Opt into SMS marketing
|
|
198
|
-
await window.elements.actions.checkout.toggleMarketingPreferences('canSms', true);
|
|
198
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleMarketingPreferences('canSms', true);
|
|
199
199
|
```
|
|
200
200
|
|
|
201
201
|
### Update Customer Information
|
|
@@ -203,7 +203,7 @@ await window.elements.actions.checkout.toggleMarketingPreferences('canSms', true
|
|
|
203
203
|
Pre-fill customer information:
|
|
204
204
|
|
|
205
205
|
```javascript
|
|
206
|
-
window.elements.actions.checkout.updateCustomerInfo({
|
|
206
|
+
window.LiquidCommerce.elements.actions.checkout.updateCustomerInfo({
|
|
207
207
|
firstName: 'John',
|
|
208
208
|
lastName: 'Doe',
|
|
209
209
|
email: 'john@example.com',
|
|
@@ -225,7 +225,7 @@ window.elements.actions.checkout.updateCustomerInfo({
|
|
|
225
225
|
Pre-fill gift recipient information:
|
|
226
226
|
|
|
227
227
|
```javascript
|
|
228
|
-
window.elements.actions.checkout.updateGiftInfo({
|
|
228
|
+
window.LiquidCommerce.elements.actions.checkout.updateGiftInfo({
|
|
229
229
|
firstName: 'Jane',
|
|
230
230
|
lastName: 'Smith',
|
|
231
231
|
email: 'jane@example.com',
|
|
@@ -246,7 +246,7 @@ window.elements.actions.checkout.updateGiftInfo({
|
|
|
246
246
|
Pre-fill billing address:
|
|
247
247
|
|
|
248
248
|
```javascript
|
|
249
|
-
window.elements.actions.checkout.updateBillingInfo({
|
|
249
|
+
window.LiquidCommerce.elements.actions.checkout.updateBillingInfo({
|
|
250
250
|
firstName: 'John',
|
|
251
251
|
lastName: 'Doe',
|
|
252
252
|
email: 'john@example.com',
|
|
@@ -268,7 +268,7 @@ window.elements.actions.checkout.updateBillingInfo({
|
|
|
268
268
|
### Get Checkout Details
|
|
269
269
|
|
|
270
270
|
```javascript
|
|
271
|
-
const checkoutData = window.elements.actions.checkout.getDetails();
|
|
271
|
+
const checkoutData = window.LiquidCommerce.elements.actions.checkout.getDetails();
|
|
272
272
|
|
|
273
273
|
console.log(checkoutData);
|
|
274
274
|
// {
|
|
@@ -532,7 +532,7 @@ If you have customer data, pre-fill it:
|
|
|
532
532
|
// After user logs in
|
|
533
533
|
if (userIsLoggedIn) {
|
|
534
534
|
window.addEventListener('lce:actions.checkout_opened', () => {
|
|
535
|
-
window.elements.actions.checkout.updateCustomerInfo({
|
|
535
|
+
window.LiquidCommerce.elements.actions.checkout.updateCustomerInfo({
|
|
536
536
|
firstName: currentUser.firstName,
|
|
537
537
|
lastName: currentUser.lastName,
|
|
538
538
|
email: currentUser.email,
|
|
@@ -637,10 +637,10 @@ checkout: {
|
|
|
637
637
|
|
|
638
638
|
### Checkout Not Opening
|
|
639
639
|
|
|
640
|
-
1. Verify cart has items: `window.elements.actions.cart.getDetails()`
|
|
640
|
+
1. Verify cart has items: `window.LiquidCommerce.elements.actions.cart.getDetails()`
|
|
641
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()`
|
|
642
|
+
3. Ensure SDK is initialized: `window.LiquidCommerce.elements`
|
|
643
|
+
4. Try manually: `window.LiquidCommerce.elements.actions.checkout.openCheckout()`
|
|
644
644
|
|
|
645
645
|
### Payment Form Not Loading
|
|
646
646
|
|
|
@@ -212,7 +212,7 @@ Programmatically interact with products:
|
|
|
212
212
|
Retrieve product information:
|
|
213
213
|
|
|
214
214
|
```javascript
|
|
215
|
-
const productData = window.elements.actions.product.getDetails('00619947000020');
|
|
215
|
+
const productData = window.LiquidCommerce.elements.actions.product.getDetails('00619947000020');
|
|
216
216
|
|
|
217
217
|
console.log(productData);
|
|
218
218
|
// {
|
|
@@ -388,10 +388,10 @@ Set address programmatically to skip prompting:
|
|
|
388
388
|
|
|
389
389
|
```javascript
|
|
390
390
|
// Using Google Places ID
|
|
391
|
-
await window.elements.actions.address.setAddressByPlacesId('ChIJ...');
|
|
391
|
+
await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId('ChIJ...');
|
|
392
392
|
|
|
393
393
|
// Or manually
|
|
394
|
-
await window.elements.actions.address.setAddressManually(
|
|
394
|
+
await window.LiquidCommerce.elements.actions.address.setAddressManually(
|
|
395
395
|
{
|
|
396
396
|
one: '123 Main St',
|
|
397
397
|
two: 'Apt 4',
|
|
@@ -423,7 +423,7 @@ Presale products are handled automatically; no special configuration needed.
|
|
|
423
423
|
Force a product to reload and rerender:
|
|
424
424
|
|
|
425
425
|
```javascript
|
|
426
|
-
const components = window.elements.getInjectedComponents();
|
|
426
|
+
const components = window.LiquidCommerce.elements.getInjectedComponents();
|
|
427
427
|
const productComponent = components.get('product-1');
|
|
428
428
|
|
|
429
429
|
if (productComponent) {
|
|
@@ -656,7 +656,7 @@ document.querySelectorAll('.product-placeholder').forEach(el => {
|
|
|
656
656
|
1. Check browser console for errors
|
|
657
657
|
2. Verify container ID exists in the DOM
|
|
658
658
|
3. Confirm product identifier is valid
|
|
659
|
-
4. Check that SDK is initialized (`window.elements` exists)
|
|
659
|
+
4. Check that SDK is initialized (`window.LiquidCommerce.elements` exists)
|
|
660
660
|
|
|
661
661
|
### Wrong Pricing
|
|
662
662
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Next.js Integration
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The SDK is SSR-safe out of the box. When imported on the server, a lightweight stub is resolved automatically via the `node` export condition — no dynamic imports or special configuration required. The real SDK activates on the client.
|
|
4
4
|
|
|
5
5
|
## App Router (Client Component)
|
|
6
6
|
|
|
@@ -48,9 +48,18 @@ export default function ProductPage() {
|
|
|
48
48
|
}
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
## SSR Behavior
|
|
52
|
+
|
|
53
|
+
When the module is evaluated during SSR (server components, `getServerSideProps`, middleware, etc.):
|
|
54
|
+
|
|
55
|
+
- All **types and enums** are available — TypeScript works identically.
|
|
56
|
+
- `Elements()` and `ElementsBuilder()` return `null` and log a warning.
|
|
57
|
+
- No browser APIs (`window`, `document`, `navigator`) are accessed.
|
|
58
|
+
|
|
59
|
+
You do **not** need `next/dynamic`, conditional `import()`, or `typeof window` guards in your own code.
|
|
60
|
+
|
|
51
61
|
## Notes
|
|
52
62
|
|
|
53
|
-
- Do not initialize server-side (Window/Document required).
|
|
54
63
|
- For ad blocker mitigation, configure the proxy (see [Proxy Setup](./proxy-setup.md)).
|
|
55
64
|
|
|
56
65
|
## Related Docs
|
|
@@ -44,8 +44,8 @@ import { useEffect } from 'react';
|
|
|
44
44
|
|
|
45
45
|
export default function CartButton() {
|
|
46
46
|
useEffect(() => {
|
|
47
|
-
if (!window.elements) return;
|
|
48
|
-
window.elements.ui.cartButton('header-cart', true);
|
|
47
|
+
if (!window.LiquidCommerce.elements) return;
|
|
48
|
+
window.LiquidCommerce.elements.ui.cartButton('header-cart', true);
|
|
49
49
|
}, []);
|
|
50
50
|
|
|
51
51
|
return <div id="header-cart"></div>;
|
|
@@ -54,7 +54,7 @@ export default function CartButton() {
|
|
|
54
54
|
|
|
55
55
|
## Notes
|
|
56
56
|
|
|
57
|
-
-
|
|
57
|
+
- The SDK is SSR-safe — importing it on the server resolves a no-op stub automatically. Initialize in `useEffect` to get the real client.
|
|
58
58
|
- For multiple products, call `injectProductElement` with multiple entries.
|
|
59
59
|
|
|
60
60
|
## Related Docs
|
|
@@ -51,7 +51,7 @@ Use the CDN build for the fastest setup, or use NPM if you have a build step.
|
|
|
51
51
|
|
|
52
52
|
<script>
|
|
53
53
|
window.addEventListener('lce:actions.client_ready', async () => {
|
|
54
|
-
const client = window.elements;
|
|
54
|
+
const client = window.LiquidCommerce.elements;
|
|
55
55
|
await client.injectProductElement([
|
|
56
56
|
{ containerId: 'product', identifier: '00619947000020' }
|
|
57
57
|
]);
|