@liquidcommerce/elements-sdk 2.5.1 → 2.5.2-beta.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 +206 -0
- package/dist/index.esm.js +9193 -9193
- package/docs/CONFIGURATION.md +94 -0
- package/docs/DOCUMENTATION_INDEX.md +1 -0
- package/package.json +1 -1
- package/umd/elements.js +1 -1
package/README.md
CHANGED
|
@@ -192,6 +192,40 @@ Mark any div with a data attribute:
|
|
|
192
192
|
|
|
193
193
|
**Use case:** Product grids, category pages, search results
|
|
194
194
|
|
|
195
|
+
### Adding a Product List
|
|
196
|
+
|
|
197
|
+
Display a filtered, paginated product catalog with infinite scroll. Perfect for category pages, catalog pages, and search results.
|
|
198
|
+
|
|
199
|
+
Add a product list to any page with a data attribute:
|
|
200
|
+
|
|
201
|
+
```html
|
|
202
|
+
<div data-liquid-commerce-elements-products-list
|
|
203
|
+
data-card="standard"
|
|
204
|
+
data-rows="3"
|
|
205
|
+
data-columns="4"
|
|
206
|
+
data-filters="personalization,pre-order,delivery-options"
|
|
207
|
+
data-product-url="/product/{upc}">
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
<script
|
|
211
|
+
data-liquid-commerce-elements
|
|
212
|
+
data-token="YOUR_API_KEY"
|
|
213
|
+
data-env="production"
|
|
214
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
215
|
+
></script>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Attributes:**
|
|
219
|
+
- `data-liquid-commerce-elements-products-list` - Enables product list on this div
|
|
220
|
+
- `data-card` - Card variant: `standard` (default)
|
|
221
|
+
- `data-rows` - Number of rows per page (default: `3`)
|
|
222
|
+
- `data-columns` - Number of columns (default: `4`)
|
|
223
|
+
- `data-card-fill` - Makes cards fill available space (optional flag)
|
|
224
|
+
- `data-filters` - Comma-separated filters: `personalization`, `pre-order`, `delivery-options`
|
|
225
|
+
- `data-product-url` - Product URL template with `{upc}` or `{grouping}` placeholder
|
|
226
|
+
|
|
227
|
+
**Use case:** Category pages, catalog pages, search results, filtered product browsing
|
|
228
|
+
|
|
195
229
|
### Customizing the Cart Button
|
|
196
230
|
|
|
197
231
|
By default, you get a floating cart button. Here's how to customize it:
|
|
@@ -339,6 +373,16 @@ Here's every available data attribute:
|
|
|
339
373
|
data-container-2="div-id"
|
|
340
374
|
data-product-2="identifier"
|
|
341
375
|
|
|
376
|
+
<!-- Product List -->
|
|
377
|
+
<div data-liquid-commerce-elements-products-list
|
|
378
|
+
data-card="standard"
|
|
379
|
+
data-rows="3"
|
|
380
|
+
data-columns="4"
|
|
381
|
+
data-card-fill
|
|
382
|
+
data-filters="personalization,pre-order,delivery-options"
|
|
383
|
+
data-product-url="/product/{upc}">
|
|
384
|
+
</div>
|
|
385
|
+
|
|
342
386
|
<!-- URL Parameters -->
|
|
343
387
|
data-product-param="lce_product"
|
|
344
388
|
data-product-fulfillment-type-param="lce_fulfillment"
|
|
@@ -621,6 +665,46 @@ const component = await client.injectAddressElement('address-container');
|
|
|
621
665
|
|
|
622
666
|
**Use case:** Shipping address collection page
|
|
623
667
|
|
|
668
|
+
#### Product List
|
|
669
|
+
|
|
670
|
+
```js
|
|
671
|
+
await client.injectProductList({
|
|
672
|
+
containerId: 'product-list-container',
|
|
673
|
+
rows: 3, // Number of rows per page
|
|
674
|
+
columns: 4, // Number of columns
|
|
675
|
+
cardVariant: 'standard', // Card style variant
|
|
676
|
+
fillCard: false, // Fill card to available space
|
|
677
|
+
filters: [ // Optional filters
|
|
678
|
+
'personalization', // Show personalized products
|
|
679
|
+
'pre-order', // Show pre-order products
|
|
680
|
+
'delivery-options' // Show delivery type filters
|
|
681
|
+
],
|
|
682
|
+
productUrl: '/product/{upc}' // Optional: Product detail page URL template
|
|
683
|
+
});
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
**Parameters:**
|
|
687
|
+
- `containerId` - Where to inject the product list
|
|
688
|
+
- `rows` - Number of rows to display per page (default: `3`)
|
|
689
|
+
- `columns` - Number of columns in the grid (default: `4`)
|
|
690
|
+
- `cardVariant` - Card display style: `'standard'` (default)
|
|
691
|
+
- `fillCard` - Whether cards should fill available space (default: `false`)
|
|
692
|
+
- `filters` - Array of filter types to enable: `'personalization'`, `'pre-order'`, `'delivery-options'`
|
|
693
|
+
- `productUrl` - Optional URL template for product links. Use `{upc}` or `{grouping}` placeholder
|
|
694
|
+
|
|
695
|
+
**Features:**
|
|
696
|
+
- ✅ Infinite scroll pagination
|
|
697
|
+
- ✅ Filter by personalization, pre-order, delivery options
|
|
698
|
+
- ✅ Address-aware (reloads when address changes)
|
|
699
|
+
- ✅ Loading states and error handling
|
|
700
|
+
- ✅ Automatic GTM tracking (`view_item_list`, `select_item`)
|
|
701
|
+
- ✅ Add to cart directly from cards
|
|
702
|
+
- ✅ Product links with tracking
|
|
703
|
+
|
|
704
|
+
**Use case:** Category pages, catalog pages, search results, filtered product browsing
|
|
705
|
+
|
|
706
|
+
**Note:** The product list automatically reloads when the address changes to show availability for the new location.
|
|
707
|
+
|
|
624
708
|
#### Access All Injected Components
|
|
625
709
|
|
|
626
710
|
```js
|
|
@@ -1455,6 +1539,128 @@ window.addEventListener('lce:actions.product_add_to_cart', (event) => {
|
|
|
1455
1539
|
});
|
|
1456
1540
|
```
|
|
1457
1541
|
|
|
1542
|
+
### Product List
|
|
1543
|
+
|
|
1544
|
+
Display a filtered, paginated product catalog with infinite scroll. Perfect for category pages, catalog pages, and search results.
|
|
1545
|
+
|
|
1546
|
+
#### Auto-Initialization
|
|
1547
|
+
|
|
1548
|
+
Add a product list to any page with data attributes:
|
|
1549
|
+
|
|
1550
|
+
```html
|
|
1551
|
+
<div data-liquid-commerce-elements-products-list
|
|
1552
|
+
data-card="standard"
|
|
1553
|
+
data-rows="3"
|
|
1554
|
+
data-columns="4"
|
|
1555
|
+
data-filters="personalization,pre-order,delivery-options"
|
|
1556
|
+
data-product-url="/product/{upc}">
|
|
1557
|
+
</div>
|
|
1558
|
+
```
|
|
1559
|
+
|
|
1560
|
+
#### Programmatic Injection
|
|
1561
|
+
|
|
1562
|
+
```js
|
|
1563
|
+
await client.injectProductList({
|
|
1564
|
+
containerId: 'product-list-container',
|
|
1565
|
+
rows: 3,
|
|
1566
|
+
columns: 4,
|
|
1567
|
+
cardVariant: 'standard',
|
|
1568
|
+
fillCard: false,
|
|
1569
|
+
filters: ['personalization', 'pre-order', 'delivery-options'],
|
|
1570
|
+
productUrl: '/product/{upc}'
|
|
1571
|
+
});
|
|
1572
|
+
```
|
|
1573
|
+
|
|
1574
|
+
#### Features
|
|
1575
|
+
|
|
1576
|
+
**Filtering:**
|
|
1577
|
+
- **Personalization filter** - Show only products that support engraving/personalization
|
|
1578
|
+
- **Pre-order filter** - Show only pre-order products
|
|
1579
|
+
- **Delivery options filter** - Filter by `all`, `shipping`, or `onDemand`
|
|
1580
|
+
|
|
1581
|
+
**Smart Filter Logic:**
|
|
1582
|
+
- When "Same-Day Delivery" is selected, personalization and pre-order filters are automatically disabled
|
|
1583
|
+
- When personalization or pre-order is enabled, same-day delivery is automatically disabled
|
|
1584
|
+
- Filters work together intelligently to show only compatible product combinations
|
|
1585
|
+
|
|
1586
|
+
**Infinite Scroll:**
|
|
1587
|
+
- Automatically loads more products as you scroll
|
|
1588
|
+
- Shows loading states during pagination
|
|
1589
|
+
- Handles "no more products" gracefully
|
|
1590
|
+
|
|
1591
|
+
**Address-Aware:**
|
|
1592
|
+
- Automatically reloads when address changes
|
|
1593
|
+
- Shows availability based on current location
|
|
1594
|
+
- Updates product pricing and fulfillment options dynamically
|
|
1595
|
+
|
|
1596
|
+
**Product Cards:**
|
|
1597
|
+
- Display product image, name, size, and price
|
|
1598
|
+
- Show availability status based on location
|
|
1599
|
+
- "Add to Cart" button (disabled if unavailable)
|
|
1600
|
+
- Clickable product links (if `productUrl` is provided)
|
|
1601
|
+
- Presale product support with special handling
|
|
1602
|
+
|
|
1603
|
+
**Analytics Tracking:**
|
|
1604
|
+
- Automatically tracks `view_item_list` when products load
|
|
1605
|
+
- Tracks `select_item` when user clicks a product link
|
|
1606
|
+
- GTM integration for e-commerce events
|
|
1607
|
+
|
|
1608
|
+
**Loading States:**
|
|
1609
|
+
- Shows skeleton loading cards during initial load
|
|
1610
|
+
- Displays loading indicator during infinite scroll
|
|
1611
|
+
- Error handling with user-friendly messages
|
|
1612
|
+
|
|
1613
|
+
**Product URL Templates:**
|
|
1614
|
+
- Use `{upc}` placeholder for UPC-based URLs: `/product/{upc}`
|
|
1615
|
+
- Use `{grouping}` placeholder for Salsify grouping IDs: `/product/{grouping}`
|
|
1616
|
+
- Links open in new tab with proper security attributes
|
|
1617
|
+
|
|
1618
|
+
#### Example: Category Page
|
|
1619
|
+
|
|
1620
|
+
```html
|
|
1621
|
+
<div id="category-products"
|
|
1622
|
+
data-liquid-commerce-elements-products-list
|
|
1623
|
+
data-card="standard"
|
|
1624
|
+
data-rows="4"
|
|
1625
|
+
data-columns="4"
|
|
1626
|
+
data-filters="personalization,delivery-options"
|
|
1627
|
+
data-product-url="/products/{upc}">
|
|
1628
|
+
</div>
|
|
1629
|
+
|
|
1630
|
+
<script
|
|
1631
|
+
data-liquid-commerce-elements
|
|
1632
|
+
data-token="YOUR_API_KEY"
|
|
1633
|
+
data-env="production"
|
|
1634
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
1635
|
+
></script>
|
|
1636
|
+
```
|
|
1637
|
+
|
|
1638
|
+
#### Example: Search Results
|
|
1639
|
+
|
|
1640
|
+
```js
|
|
1641
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
1642
|
+
env: 'production'
|
|
1643
|
+
});
|
|
1644
|
+
|
|
1645
|
+
await client.injectProductList({
|
|
1646
|
+
containerId: 'search-results',
|
|
1647
|
+
rows: 6,
|
|
1648
|
+
columns: 3,
|
|
1649
|
+
cardVariant: 'standard',
|
|
1650
|
+
fillCard: true,
|
|
1651
|
+
filters: ['delivery-options'],
|
|
1652
|
+
productUrl: '/search?q={grouping}'
|
|
1653
|
+
});
|
|
1654
|
+
```
|
|
1655
|
+
|
|
1656
|
+
**Use cases:**
|
|
1657
|
+
- Category pages
|
|
1658
|
+
- Catalog pages
|
|
1659
|
+
- Search results
|
|
1660
|
+
- Filtered product browsing
|
|
1661
|
+
- Personalized product recommendations
|
|
1662
|
+
- Pre-order product showcases
|
|
1663
|
+
|
|
1458
1664
|
---
|
|
1459
1665
|
|
|
1460
1666
|
## 🔧 Core Capabilities
|