@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,216 @@
|
|
|
1
|
+
# Theming Guide
|
|
2
|
+
|
|
3
|
+
Customize the appearance of Elements SDK components to match your brand.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The SDK provides extensive theming capabilities through the `customTheme` configuration option. Themes are structured hierarchically:
|
|
8
|
+
|
|
9
|
+
- **Global**: Colors, fonts, and styles that apply to all components
|
|
10
|
+
- **Component-specific**: Overrides for individual components
|
|
11
|
+
|
|
12
|
+
## Global Theme Configuration
|
|
13
|
+
|
|
14
|
+
### Colors
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
18
|
+
env: 'production',
|
|
19
|
+
customTheme: {
|
|
20
|
+
global: {
|
|
21
|
+
theme: {
|
|
22
|
+
primaryColor: '#007bff',
|
|
23
|
+
accentColor: '#28a745',
|
|
24
|
+
defaultTextColor: '#333333',
|
|
25
|
+
selectedTextColor: '#007bff',
|
|
26
|
+
linkTextColor: '#0056b3',
|
|
27
|
+
errorColor: '#dc3545',
|
|
28
|
+
warningColor: '#ffc107',
|
|
29
|
+
successColor: '#28a745',
|
|
30
|
+
drawerBackgroundColor: '#ffffff'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Typography
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
customTheme: {
|
|
41
|
+
global: {
|
|
42
|
+
theme: {
|
|
43
|
+
headingFont: {
|
|
44
|
+
name: 'Poppins',
|
|
45
|
+
weights: [400, 600, 700]
|
|
46
|
+
},
|
|
47
|
+
paragraphFont: {
|
|
48
|
+
name: 'Inter',
|
|
49
|
+
weights: [400, 500]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Border Radius
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
customTheme: {
|
|
60
|
+
global: {
|
|
61
|
+
theme: {
|
|
62
|
+
buttonCornerRadius: '8px',
|
|
63
|
+
cardCornerRadius: '12px'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Global Layout Options
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
customTheme: {
|
|
73
|
+
global: {
|
|
74
|
+
layout: {
|
|
75
|
+
enablePersonalization: true,
|
|
76
|
+
personalizationText: 'Add Engraving',
|
|
77
|
+
personalizationCardStyle: 'outlined', // or 'filled'
|
|
78
|
+
allowPromoCodes: true,
|
|
79
|
+
inputFieldStyle: 'outlined', // or 'filled'
|
|
80
|
+
showPoweredBy: true,
|
|
81
|
+
poweredByMode: 'light' // or 'dark'
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Component Themes
|
|
88
|
+
|
|
89
|
+
### Product Component
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
92
|
+
customTheme: {
|
|
93
|
+
product: {
|
|
94
|
+
theme: {
|
|
95
|
+
backgroundColor: '#ffffff'
|
|
96
|
+
},
|
|
97
|
+
layout: {
|
|
98
|
+
showImages: true,
|
|
99
|
+
showOnlyMainImage: false,
|
|
100
|
+
showTitle: true,
|
|
101
|
+
showDescription: true,
|
|
102
|
+
showQuantityCounter: true,
|
|
103
|
+
quantityCounterStyle: 'outlined',
|
|
104
|
+
fulfillmentDisplay: 'carousel',
|
|
105
|
+
enableShippingFulfillment: true,
|
|
106
|
+
enableOnDemandFulfillment: true,
|
|
107
|
+
addToCartButtonText: 'Add to Cart',
|
|
108
|
+
addToCartButtonShowTotalPrice: true,
|
|
109
|
+
buyNowButtonText: 'Buy Now',
|
|
110
|
+
prioritizeEngraving: false,
|
|
111
|
+
noAvailabilityText: 'Not available in your area'
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Cart Component
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
customTheme: {
|
|
121
|
+
cart: {
|
|
122
|
+
theme: {
|
|
123
|
+
backgroundColor: '#ffffff'
|
|
124
|
+
},
|
|
125
|
+
layout: {
|
|
126
|
+
showQuantityCounter: true,
|
|
127
|
+
quantityCounterStyle: 'outlined',
|
|
128
|
+
drawerHeaderText: 'Your Shopping Cart',
|
|
129
|
+
goToCheckoutButtonText: 'Proceed to Checkout'
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Checkout Component
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
customTheme: {
|
|
139
|
+
checkout: {
|
|
140
|
+
theme: {
|
|
141
|
+
backgroundColor: '#ffffff'
|
|
142
|
+
},
|
|
143
|
+
layout: {
|
|
144
|
+
emailOptIn: {
|
|
145
|
+
show: true,
|
|
146
|
+
checked: false,
|
|
147
|
+
text: 'Subscribe to our newsletter for updates and offers.'
|
|
148
|
+
},
|
|
149
|
+
smsOptIn: {
|
|
150
|
+
show: true,
|
|
151
|
+
checked: false,
|
|
152
|
+
text: 'Receive SMS updates about your order and exclusive deals.'
|
|
153
|
+
},
|
|
154
|
+
allowGiftCards: true,
|
|
155
|
+
legalMessage: 'By placing your order, you agree to our Terms of Service and Privacy Policy.',
|
|
156
|
+
continueShoppingUrl: 'https://yoursite.com/shop',
|
|
157
|
+
exitUrl: 'https://yoursite.com',
|
|
158
|
+
thankYouButtonText: 'Continue Shopping',
|
|
159
|
+
drawerHeaderText: 'Checkout',
|
|
160
|
+
placeOrderButtonText: 'Place Order',
|
|
161
|
+
checkoutCompleted: {
|
|
162
|
+
customLogo: 'https://yoursite.com/logo.png',
|
|
163
|
+
customText: 'Thank you for your purchase! Your order has been received.'
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Complete Example
|
|
172
|
+
|
|
173
|
+
```javascript
|
|
174
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
175
|
+
env: 'production',
|
|
176
|
+
customTheme: {
|
|
177
|
+
global: {
|
|
178
|
+
theme: {
|
|
179
|
+
primaryColor: '#007bff',
|
|
180
|
+
accentColor: '#28a745',
|
|
181
|
+
buttonCornerRadius: '8px',
|
|
182
|
+
cardCornerRadius: '12px',
|
|
183
|
+
headingFont: {
|
|
184
|
+
name: 'Poppins',
|
|
185
|
+
weights: [400, 600, 700]
|
|
186
|
+
},
|
|
187
|
+
paragraphFont: {
|
|
188
|
+
name: 'Inter',
|
|
189
|
+
weights: [400, 500]
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
layout: {
|
|
193
|
+
allowPromoCodes: true,
|
|
194
|
+
inputFieldStyle: 'outlined',
|
|
195
|
+
showPoweredBy: false
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
product: {
|
|
199
|
+
layout: {
|
|
200
|
+
addToCartButtonText: 'Add to Bag',
|
|
201
|
+
fulfillmentDisplay: 'popup'
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
cart: {
|
|
205
|
+
layout: {
|
|
206
|
+
checkoutButtonText: 'Checkout Now'
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## See Also
|
|
214
|
+
|
|
215
|
+
- [Configuration Reference](../api/configuration.md)
|
|
216
|
+
- [Component Guides](../guides/)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Angular Integration
|
|
2
|
+
|
|
3
|
+
Initialize Elements in a browser-only lifecycle hook and inject the component after the view mounts.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @liquidcommerce/elements-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Standalone Component Example
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { AfterViewInit, Component } from '@angular/core';
|
|
15
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'app-product-page',
|
|
19
|
+
standalone: true,
|
|
20
|
+
template: '<div id="product"></div>'
|
|
21
|
+
})
|
|
22
|
+
export class ProductPageComponent implements AfterViewInit {
|
|
23
|
+
async ngAfterViewInit() {
|
|
24
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
25
|
+
await client.injectProductElement([
|
|
26
|
+
{ containerId: 'product', identifier: '00619947000020' }
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Notes
|
|
33
|
+
|
|
34
|
+
- Initialize only in the browser (not during server rendering).
|
|
35
|
+
|
|
36
|
+
## Related Docs
|
|
37
|
+
|
|
38
|
+
- [Product Component](../guides/product-component.md)
|
|
39
|
+
- [Client API](../api/client.md)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Laravel Integration
|
|
2
|
+
|
|
3
|
+
Use the CDN build in a Blade view for a quick server-rendered setup.
|
|
4
|
+
|
|
5
|
+
## Blade Template (CDN)
|
|
6
|
+
|
|
7
|
+
```blade
|
|
8
|
+
<!-- resources/views/product.blade.php -->
|
|
9
|
+
<!DOCTYPE html>
|
|
10
|
+
<html lang="en">
|
|
11
|
+
<head>
|
|
12
|
+
<meta charset="UTF-8">
|
|
13
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
14
|
+
<title>Product</title>
|
|
15
|
+
|
|
16
|
+
<script
|
|
17
|
+
defer
|
|
18
|
+
data-liquid-commerce-elements
|
|
19
|
+
data-token="{{ env('LCE_API_KEY') }}"
|
|
20
|
+
data-env="production"
|
|
21
|
+
data-container-1="product"
|
|
22
|
+
data-product-1="00619947000020"
|
|
23
|
+
type="text/javascript"
|
|
24
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
25
|
+
></script>
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<div id="product"></div>
|
|
29
|
+
</body>
|
|
30
|
+
</html>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Notes
|
|
34
|
+
|
|
35
|
+
- Keep your API key in `.env` and reference it in Blade.
|
|
36
|
+
- You can add a cart button with `data-cart-badge-button` on the script tag.
|
|
37
|
+
|
|
38
|
+
## Related Docs
|
|
39
|
+
|
|
40
|
+
- [Product Component](../guides/product-component.md)
|
|
41
|
+
- [Cart Component](../guides/cart-component.md)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Next.js Integration
|
|
2
|
+
|
|
3
|
+
Use a client component (App Router) or `useEffect` in a client-only page (Pages Router). Initialize the SDK on the client.
|
|
4
|
+
|
|
5
|
+
## App Router (Client Component)
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
'use client';
|
|
9
|
+
|
|
10
|
+
import { useEffect } from 'react';
|
|
11
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
12
|
+
|
|
13
|
+
export default function ProductPage() {
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
(async () => {
|
|
16
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
17
|
+
env: 'production',
|
|
18
|
+
proxy: { baseUrl: '/api/elements-proxy' }
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
await client.injectProductElement([
|
|
22
|
+
{ containerId: 'product', identifier: '00619947000020' }
|
|
23
|
+
]);
|
|
24
|
+
})();
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
return <div id="product"></div>;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Pages Router
|
|
32
|
+
|
|
33
|
+
```jsx
|
|
34
|
+
import { useEffect } from 'react';
|
|
35
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
36
|
+
|
|
37
|
+
export default function ProductPage() {
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
(async () => {
|
|
40
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
41
|
+
await client.injectProductElement([
|
|
42
|
+
{ containerId: 'product', identifier: '00619947000020' }
|
|
43
|
+
]);
|
|
44
|
+
})();
|
|
45
|
+
}, []);
|
|
46
|
+
|
|
47
|
+
return <div id="product"></div>;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Notes
|
|
52
|
+
|
|
53
|
+
- Do not initialize server-side (Window/Document required).
|
|
54
|
+
- For ad blocker mitigation, configure the proxy (see [Proxy Setup](./proxy-setup.md)).
|
|
55
|
+
|
|
56
|
+
## Related Docs
|
|
57
|
+
|
|
58
|
+
- [Proxy Setup](./proxy-setup.md)
|
|
59
|
+
- [Product Component](../guides/product-component.md)
|
|
60
|
+
- [Client API](../api/client.md)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Proxy Setup
|
|
2
|
+
|
|
3
|
+
If ad blockers or network policies block the SDK assets, use a proxy on your domain. The SDK supports a `proxy.baseUrl` that routes API calls through your server.
|
|
4
|
+
|
|
5
|
+
## 1) Configure the SDK
|
|
6
|
+
|
|
7
|
+
### NPM
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
11
|
+
|
|
12
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
13
|
+
env: 'production',
|
|
14
|
+
proxy: {
|
|
15
|
+
baseUrl: 'https://yoursite.com/api/elements-proxy'
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### CDN (Next.js example)
|
|
21
|
+
|
|
22
|
+
```jsx
|
|
23
|
+
'use client';
|
|
24
|
+
|
|
25
|
+
import { useEffect } from 'react';
|
|
26
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
27
|
+
|
|
28
|
+
export default function ProductPage() {
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
(async () => {
|
|
31
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
32
|
+
env: 'production',
|
|
33
|
+
proxy: { baseUrl: '/api/elements-proxy' }
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await client.injectProductElement([
|
|
37
|
+
{ containerId: 'product', identifier: '00619947000020' }
|
|
38
|
+
]);
|
|
39
|
+
})();
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
return <div id="product"></div>;
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 2) Create the Proxy Endpoint
|
|
47
|
+
|
|
48
|
+
Your endpoint should forward requests to the LiquidCommerce Elements API, preserving method, headers, and body.
|
|
49
|
+
|
|
50
|
+
### Minimal Express Example
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
import express from 'express';
|
|
54
|
+
import fetch from 'node-fetch';
|
|
55
|
+
|
|
56
|
+
const app = express();
|
|
57
|
+
app.use(express.json());
|
|
58
|
+
|
|
59
|
+
app.all('/api/elements-proxy/*', async (req, res) => {
|
|
60
|
+
const targetPath = req.params[0];
|
|
61
|
+
const targetUrl = `https://api.liquidcommerce.us/${targetPath}`;
|
|
62
|
+
|
|
63
|
+
const response = await fetch(targetUrl, {
|
|
64
|
+
method: req.method,
|
|
65
|
+
headers: {
|
|
66
|
+
...req.headers,
|
|
67
|
+
host: 'api.liquidcommerce.us'
|
|
68
|
+
},
|
|
69
|
+
body: ['GET', 'HEAD'].includes(req.method) ? undefined : JSON.stringify(req.body)
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const data = await response.text();
|
|
73
|
+
res.status(response.status).send(data);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
app.listen(3000, () => {
|
|
77
|
+
console.log('Proxy listening on port 3000');
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Notes
|
|
82
|
+
|
|
83
|
+
- Keep your API key server-side whenever possible.
|
|
84
|
+
- Ensure CORS allows your storefront domain to call the proxy.
|
|
85
|
+
|
|
86
|
+
## Related Docs
|
|
87
|
+
|
|
88
|
+
- [Installation](../getting-started/installation.md)
|
|
89
|
+
- [Client API](../api/client.md)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# React Integration
|
|
2
|
+
|
|
3
|
+
Use the NPM package and initialize the SDK client on the client side. Then inject components after mount.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @liquidcommerce/elements-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Product Page
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { useEffect, useState } from 'react';
|
|
15
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
16
|
+
|
|
17
|
+
export default function ProductPage() {
|
|
18
|
+
const [client, setClient] = useState(null);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
let mounted = true;
|
|
22
|
+
(async () => {
|
|
23
|
+
const instance = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
24
|
+
if (mounted) setClient(instance);
|
|
25
|
+
})();
|
|
26
|
+
return () => { mounted = false; };
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!client) return;
|
|
31
|
+
client.injectProductElement([
|
|
32
|
+
{ containerId: 'product', identifier: '00619947000020' }
|
|
33
|
+
]);
|
|
34
|
+
}, [client]);
|
|
35
|
+
|
|
36
|
+
return <div id="product"></div>;
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Cart Button
|
|
41
|
+
|
|
42
|
+
```jsx
|
|
43
|
+
import { useEffect } from 'react';
|
|
44
|
+
|
|
45
|
+
export default function CartButton() {
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!window.elements) return;
|
|
48
|
+
window.elements.ui.cartButton('header-cart', true);
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
return <div id="header-cart"></div>;
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Notes
|
|
56
|
+
|
|
57
|
+
- Initialize only on the client; the SDK uses browser APIs.
|
|
58
|
+
- For multiple products, call `injectProductElement` with multiple entries.
|
|
59
|
+
|
|
60
|
+
## Related Docs
|
|
61
|
+
|
|
62
|
+
- [Product Component](../guides/product-component.md)
|
|
63
|
+
- [Cart Component](../guides/cart-component.md)
|
|
64
|
+
- [Client API](../api/client.md)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Vanilla JavaScript Integration
|
|
2
|
+
|
|
3
|
+
Use the CDN build for the fastest setup, or use NPM if you have a build step.
|
|
4
|
+
|
|
5
|
+
## Option A: CDN (Declarative)
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!DOCTYPE html>
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="UTF-8" />
|
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
13
|
+
<title>Vanilla JS Product Page</title>
|
|
14
|
+
|
|
15
|
+
<script
|
|
16
|
+
defer
|
|
17
|
+
data-liquid-commerce-elements
|
|
18
|
+
data-token="YOUR_API_KEY"
|
|
19
|
+
data-env="production"
|
|
20
|
+
data-container-1="product"
|
|
21
|
+
data-product-1="00619947000020"
|
|
22
|
+
data-cart-badge-button="header-cart"
|
|
23
|
+
type="text/javascript"
|
|
24
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
25
|
+
></script>
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<header>
|
|
29
|
+
<h1>Premium Spirits</h1>
|
|
30
|
+
<div id="header-cart"></div>
|
|
31
|
+
</header>
|
|
32
|
+
|
|
33
|
+
<main>
|
|
34
|
+
<div id="product"></div>
|
|
35
|
+
</main>
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Option B: CDN (Programmatic)
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<script
|
|
44
|
+
defer
|
|
45
|
+
data-liquid-commerce-elements
|
|
46
|
+
data-token="YOUR_API_KEY"
|
|
47
|
+
data-env="production"
|
|
48
|
+
type="text/javascript"
|
|
49
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
50
|
+
></script>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
window.addEventListener('lce:actions.client_ready', async () => {
|
|
54
|
+
const client = window.elements;
|
|
55
|
+
await client.injectProductElement([
|
|
56
|
+
{ containerId: 'product', identifier: '00619947000020' }
|
|
57
|
+
]);
|
|
58
|
+
});
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<div id="product"></div>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Option C: NPM
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm install @liquidcommerce/elements-sdk
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
72
|
+
|
|
73
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
74
|
+
|
|
75
|
+
await client.injectProductElement([
|
|
76
|
+
{ containerId: 'product', identifier: '00619947000020' }
|
|
77
|
+
]);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Related Docs
|
|
81
|
+
|
|
82
|
+
- [Product Component](../guides/product-component.md)
|
|
83
|
+
- [Cart Component](../guides/cart-component.md)
|
|
84
|
+
- [Client API](../api/client.md)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Vue Integration
|
|
2
|
+
|
|
3
|
+
Use the NPM package and initialize Elements in `onMounted`.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @liquidcommerce/elements-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Vue 3 (Single File Component)
|
|
12
|
+
|
|
13
|
+
```vue
|
|
14
|
+
<template>
|
|
15
|
+
<div id="product"></div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup>
|
|
19
|
+
import { onMounted } from 'vue';
|
|
20
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
21
|
+
|
|
22
|
+
onMounted(async () => {
|
|
23
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
24
|
+
await client.injectProductElement([
|
|
25
|
+
{ containerId: 'product', identifier: '00619947000020' }
|
|
26
|
+
]);
|
|
27
|
+
});
|
|
28
|
+
</script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Related Docs
|
|
32
|
+
|
|
33
|
+
- [Product Component](../guides/product-component.md)
|
|
34
|
+
- [Client API](../api/client.md)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Browser Support
|
|
2
|
+
|
|
3
|
+
The Elements SDK requires modern browser features (Web Components + Shadow DOM). If you need to support older browsers, include polyfills.
|
|
4
|
+
|
|
5
|
+
## Minimum Versions
|
|
6
|
+
|
|
7
|
+
- Chrome 66+
|
|
8
|
+
- Firefox 60+
|
|
9
|
+
- Safari 12+
|
|
10
|
+
- Edge 79+
|
|
11
|
+
|
|
12
|
+
## Required Features
|
|
13
|
+
|
|
14
|
+
- Custom Elements (Web Components)
|
|
15
|
+
- Shadow DOM
|
|
16
|
+
- ES2018 JavaScript
|
|
17
|
+
- Fetch API
|
|
18
|
+
- LocalStorage
|
|
19
|
+
|
|
20
|
+
## Server-Side Rendering (SSR)
|
|
21
|
+
|
|
22
|
+
The SDK is browser-only, but it is safe to import in SSR frameworks (Next.js, Remix, Nuxt).
|
|
23
|
+
In non-browser environments, initialization is skipped. If you call the SDK on the server,
|
|
24
|
+
it returns `null` and logs a warning instead of throwing.
|
|
25
|
+
|
|
26
|
+
Call `Elements`, `ElementsCheckout`, or `ElementsBuilder` from client-only code (e.g., after mount)
|
|
27
|
+
to render components.
|
|
28
|
+
|
|
29
|
+
## Polyfills (Legacy Browsers)
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-bundle.js"></script>
|
|
33
|
+
<script defer data-liquid-commerce-elements ...></script>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Notes
|
|
37
|
+
|
|
38
|
+
- Always load the SDK script with `defer` to avoid blocking page render.
|
|
39
|
+
- If you see Web Components errors in the console, add the polyfill before the SDK.
|
|
40
|
+
|
|
41
|
+
## Related Docs
|
|
42
|
+
|
|
43
|
+
- [Installation](../getting-started/installation.md)
|
|
44
|
+
- [Troubleshooting](./troubleshooting.md)
|