@liquidcommerce/elements-sdk 2.6.0-beta.38 → 2.6.0-beta.39

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.
@@ -0,0 +1,250 @@
1
+ # Product
2
+
3
+ The product element is the heart of the SDK - it displays product information, handles size and variant selection, shows real-time pricing based on delivery location, and lets customers add items to their cart.
4
+
5
+ ## Overview
6
+
7
+ The product element renders a complete product card with:
8
+ - Product imagery and details
9
+ - Size/variant selection
10
+ - Real-time pricing based on delivery address
11
+ - Fulfillment options (shipping vs on-demand delivery)
12
+ - Quantity controls
13
+ - Add to cart functionality
14
+ - Personalization/engraving options (when available)
15
+
16
+ The component automatically adapts to the customer's delivery address, showing only available fulfillment options and location-specific pricing.
17
+
18
+ ---
19
+
20
+ ## Declarative Setup (HTML Attributes)
21
+
22
+ Add products to your page without writing JavaScript. Choose the method that fits your use case.
23
+
24
+ ### Method 1: Direct Attributes
25
+
26
+ Best for static pages with known products. Add products directly in the script tag:
27
+
28
+ ```html
29
+ <div id="product-1"></div>
30
+ <div id="product-2"></div>
31
+
32
+ <script
33
+ defer
34
+ type="text/javascript"
35
+ data-liquid-commerce-elements
36
+ data-token="YOUR_API_KEY"
37
+ data-env="production"
38
+ data-container-1="product-1"
39
+ data-product-1="00619947000020"
40
+ data-container-2="product-2"
41
+ data-product-2="00832889005513"
42
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
43
+ ></script>
44
+ ```
45
+
46
+ The pattern is `data-container-N` paired with `data-product-N` where N is any number.
47
+
48
+ ### Method 2: JSON Configuration
49
+
50
+ Best for CMS platforms and dynamic content. Configure products via a JSON script block:
51
+
52
+ ```html
53
+ <div id="product-1"></div>
54
+ <div id="product-2"></div>
55
+
56
+ <script data-liquid-commerce-elements-products type="application/json">
57
+ [
58
+ { "containerId": "product-1", "identifier": "00619947000020" },
59
+ { "containerId": "product-2", "identifier": "00832889005513" }
60
+ ]
61
+ </script>
62
+
63
+ <script
64
+ defer
65
+ type="text/javascript"
66
+ data-liquid-commerce-elements
67
+ data-token="YOUR_API_KEY"
68
+ data-env="production"
69
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
70
+ ></script>
71
+ ```
72
+
73
+ This approach works well with templating engines and server-side rendering.
74
+
75
+ ### Method 3: Annotated Elements
76
+
77
+ Best for product grids and lists. Mark any div with a data attribute:
78
+
79
+ ```html
80
+ <div class="product-grid">
81
+ <div data-lce-product="00619947000020"></div>
82
+ <div data-lce-product="00832889005513"></div>
83
+ <div data-lce-product="00851468007252"></div>
84
+ </div>
85
+
86
+ <script
87
+ defer
88
+ type="text/javascript"
89
+ data-liquid-commerce-elements
90
+ data-token="YOUR_API_KEY"
91
+ data-env="production"
92
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
93
+ ></script>
94
+ ```
95
+
96
+ The SDK automatically finds and initializes all elements with `data-lce-product`.
97
+
98
+ ---
99
+
100
+ ## Programmatic Setup (JavaScript API)
101
+
102
+ For full control, inject products using the client API.
103
+
104
+ ### Basic Injection
105
+
106
+ ```javascript
107
+ const client = await Elements('YOUR_API_KEY', { env: 'production' });
108
+
109
+ const components = await client.injectProductElement([
110
+ { containerId: 'pdp-1', identifier: '00619947000020' },
111
+ { containerId: 'pdp-2', identifier: '00832889005513' }
112
+ ]);
113
+ ```
114
+
115
+ ### Parameters
116
+
117
+ | Parameter | Type | Required | Description |
118
+ |-----------|------|----------|-------------|
119
+ | `containerId` | string | Yes | ID of the container element |
120
+ | `identifier` | string | Yes | Product UPC, ID, or Salsify grouping ID |
121
+
122
+ ### Return Value
123
+
124
+ Returns `IInjectedComponent[]` - an array of component wrappers with these methods:
125
+
126
+ ```javascript
127
+ // Get the container element
128
+ const element = components[0].getElement();
129
+
130
+ // Get the component type
131
+ const type = components[0].getType(); // 'product'
132
+
133
+ // Force a re-render
134
+ components[0].rerender();
135
+ ```
136
+
137
+ ### Dynamic Product Loading
138
+
139
+ Load products dynamically based on user actions:
140
+
141
+ ```javascript
142
+ // Load product when user clicks a button
143
+ document.querySelector('#load-product').addEventListener('click', async () => {
144
+ await client.injectProductElement([
145
+ { containerId: 'dynamic-product', identifier: selectedProductId }
146
+ ]);
147
+ });
148
+ ```
149
+
150
+ ---
151
+
152
+ ## Actions
153
+
154
+ Control and query product state programmatically.
155
+
156
+ ### Get Product Details
157
+
158
+ Retrieve the current state of a displayed product:
159
+
160
+ ```javascript
161
+ const details = window.elements.actions.product.getDetails('00619947000020');
162
+
163
+ // Returns product data including:
164
+ // - name, brand, category
165
+ // - selectedSizeId, selectedFulfillmentType
166
+ // - availability status
167
+ // - pricing information
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Events
173
+
174
+ Listen to product interactions and state changes.
175
+
176
+ ### Subscribing to Events
177
+
178
+ ```javascript
179
+ window.addEventListener('lce:actions.product_loaded', (event) => {
180
+ const { data, metadata } = event.detail;
181
+ console.log('Product loaded:', data.name);
182
+ });
183
+ ```
184
+
185
+ ### Available Events
186
+
187
+ | Event | Description | Key Data |
188
+ |-------|-------------|----------|
189
+ | `product_loaded` | Product data fetched and displayed | Full product details |
190
+ | `product_add_to_cart` | Customer added product to cart | identifier, fulfillmentId, quantity |
191
+ | `product_quantity_increase` | Quantity increased | identifier, quantity, previousQuantity |
192
+ | `product_quantity_decrease` | Quantity decreased | identifier, quantity, previousQuantity |
193
+ | `product_size_changed` | Size selection changed | identifier, selectedSizeId, previousSizeId |
194
+ | `product_fulfillment_type_changed` | Shipping/on-demand changed | identifier, selectedFulfillmentType |
195
+ | `product_fulfillment_changed` | Retailer selection changed | identifier, selectedFulfillmentId |
196
+
197
+ ### Example: Track Add to Cart
198
+
199
+ ```javascript
200
+ window.addEventListener('lce:actions.product_add_to_cart', (event) => {
201
+ const { identifier, quantity, fulfillmentId } = event.detail.data;
202
+
203
+ // Send to analytics
204
+ analytics.track('Product Added', {
205
+ productId: identifier,
206
+ quantity: quantity,
207
+ fulfillment: fulfillmentId
208
+ });
209
+ });
210
+ ```
211
+
212
+ ---
213
+
214
+ ## Customization
215
+
216
+ Style product components through the theme configuration.
217
+
218
+ ### Basic Theming
219
+
220
+ ```javascript
221
+ const client = await Elements('YOUR_API_KEY', {
222
+ customTheme: {
223
+ global: {
224
+ theme: {
225
+ primaryColor: '#007bff',
226
+ buttonCornerRadius: '8px'
227
+ }
228
+ },
229
+ product: {
230
+ // Product-specific theme options
231
+ }
232
+ }
233
+ });
234
+ ```
235
+
236
+ ### Product Theme Options
237
+
238
+ See [theming.md](./theming.md) for the complete list of product theme options including:
239
+ - Layout configuration
240
+ - Color overrides
241
+ - Typography settings
242
+ - Spacing and sizing
243
+
244
+ ---
245
+
246
+ ## See Also
247
+
248
+ - [Actions Reference](./actions.md) - All available actions
249
+ - [Events Reference](./events.md) - All available events
250
+ - [Theming Guide](./theming.md) - Customization options
@@ -677,5 +677,6 @@ customTheme: {
677
677
 
678
678
  ## Related Documentation
679
679
 
680
- - [Configuration Reference](./CONFIGURATION.md) - All SDK configuration options
681
- - [Troubleshooting Guide](./TROUBLESHOOTING.md) - Common theming issues
680
+ - [Troubleshooting Guide](./troubleshooting.md) - Common theming issues
681
+ - [Actions Reference](./actions.md) - Programmatic control
682
+ - [Events Reference](./events.md) - Event system
@@ -54,7 +54,7 @@ Cart items have location-specific pricing, availability, and fulfillment options
54
54
 
55
55
  #### 3. Ad Blockers
56
56
 
57
- **Solution:** Configure a [proxy](./PROXY.md) to route requests through your domain.
57
+ **Solution:** Configure a [proxy](./proxy.md) to route requests through your domain.
58
58
 
59
59
  ### Authentication Failures
60
60
 
@@ -785,9 +785,9 @@ If you're still experiencing issues:
785
785
 
786
786
  ## Related Documentation
787
787
 
788
- - [Configuration Reference](./CONFIGURATION.md) - Configuration options
789
- - [Actions Reference](./ACTIONS.md) - Programmatic control
790
- - [Events Reference](./EVENTS.md) - Event system
791
- - [Browser Support](./BROWSER_SUPPORT.md) - Browser compatibility
792
- - [Proxy Setup](./PROXY.md) - Proxy configuration
788
+ - [Actions Reference](./actions.md) - Programmatic control
789
+ - [Events Reference](./events.md) - Event system
790
+ - [Browser Support](./browser-support.md) - Browser compatibility
791
+ - [Proxy Setup](./proxy.md) - Proxy configuration
792
+ - [Theming](./theming.md) - Customization options
793
793
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "LiquidCommerce Elements SDK",
4
4
  "license": "UNLICENSED",
5
5
  "author": "LiquidCommerce Team",
6
- "version": "2.6.0-beta.38",
6
+ "version": "2.6.0-beta.39",
7
7
  "homepage": "https://docs.liquidcommerce.co/elements-sdk",
8
8
  "repository": {
9
9
  "type": "git",