@liquidcommerce/elements-sdk 2.5.7 → 2.5.9
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 +99 -25
- package/dist/index.esm.js +12572 -11480
- package/dist/types/constants/core.constant.d.ts +1 -0
- package/dist/types/core/api-client.service.d.ts +1 -1
- package/dist/types/core/client/client-action.service.d.ts +0 -4
- package/dist/types/core/client/client-config.service.d.ts +4 -0
- package/dist/types/core/fingerprint.service.d.ts +2 -1
- package/dist/types/core/google-tag-manager.service.d.ts +0 -19
- package/dist/types/core/logger/logger.service.d.ts +0 -2
- package/dist/types/core/pubsub/interfaces/cart.interface.d.ts +0 -2
- package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +0 -10
- package/dist/types/core/pubsub/interfaces/core.interface.d.ts +14 -8
- package/dist/types/core/pubsub/interfaces/product.interface.d.ts +0 -6
- package/dist/types/core/singleton-manager.service.d.ts +6 -1
- package/dist/types/core/store/interfaces/checkout.interface.d.ts +75 -80
- package/dist/types/core/store/interfaces/core.interface.d.ts +2 -2
- package/dist/types/core/store/store.constant.d.ts +1 -1
- package/dist/types/enums/core.enum.d.ts +16 -10
- package/dist/types/interfaces/cloud/checkout.interface.d.ts +1 -1
- package/dist/types/interfaces/configs/checkout.interface.d.ts +0 -1
- package/dist/types/interfaces/core.interface.d.ts +5 -1
- package/dist/types/modules/cart/components/cart-retailer.component.d.ts +0 -2
- package/dist/types/modules/checkout/checkout.commands.d.ts +28 -25
- package/dist/types/modules/checkout/components/checkout-billing.component.d.ts +14 -0
- package/dist/types/modules/checkout/components/checkout-buyer-summary.component.d.ts +7 -0
- package/dist/types/modules/checkout/components/{checkout-information-section.component.d.ts → checkout-buyer.component.d.ts} +5 -5
- package/dist/types/modules/checkout/components/checkout-deliver-to-summary.component.d.ts +7 -0
- package/dist/types/modules/checkout/components/checkout-deliver-to.component.d.ts +13 -0
- package/dist/types/modules/checkout/components/checkout-information.component.d.ts +17 -0
- package/dist/types/modules/checkout/components/{checkout-summary-section.component.d.ts → checkout-order-summary.component.d.ts} +1 -1
- package/dist/types/modules/checkout/components/checkout-payment-summary.component.d.ts +7 -0
- package/dist/types/modules/checkout/components/checkout-payment.component.d.ts +30 -0
- package/dist/types/modules/checkout/components/{summary/checkout-place-order-button.component.d.ts → checkout-place-order-button.component.d.ts} +1 -5
- package/dist/types/modules/checkout/components/checkout-send-as-gift.component.d.ts +7 -0
- package/dist/types/modules/checkout/components/{information/checkout-stripe-form.component.d.ts → checkout-stripe-form.component.d.ts} +5 -3
- package/dist/types/modules/checkout/components/checkout-stripe-handler.component.d.ts +50 -0
- package/dist/types/modules/checkout/components/index.d.ts +23 -18
- package/dist/types/modules/checkout/constant.d.ts +0 -1
- package/dist/types/modules/product/components/components.d.ts +1 -1
- package/dist/types/modules/product/utils/helpers.d.ts +0 -7
- package/dist/types/modules/ui-components/input/birthdate-input.component.d.ts +4 -4
- package/dist/types/modules/ui-components/input/input.component.d.ts +4 -4
- package/docs/ACTIONS.md +29 -29
- package/docs/CONFIGURATION.md +20 -1
- package/docs/EVENTS.md +62 -29
- package/docs/THEMING.md +2 -5
- package/package.json +7 -7
- package/umd/elements.js +1 -1
- package/dist/types/modules/checkout/checkout.commands.helper.d.ts +0 -13
- package/dist/types/modules/checkout/components/information/checkout-billing-form.component.d.ts +0 -18
- package/dist/types/modules/checkout/components/information/checkout-buyer-information-form.component.d.ts +0 -12
- package/dist/types/modules/checkout/components/information/checkout-delivery-information-form.component.d.ts +0 -17
- package/dist/types/modules/checkout/components/information/checkout-payment-form.component.d.ts +0 -21
- package/dist/types/modules/product/utils/index.d.ts +0 -2
- /package/dist/types/modules/checkout/components/{summary/checkout-amounts.component.d.ts → checkout-amounts.component.d.ts} +0 -0
- /package/dist/types/modules/checkout/components/{summary/checkout-completed.component.d.ts → checkout-completed.component.d.ts} +0 -0
- /package/dist/types/modules/checkout/components/{summary/checkout-gift-cards.component.d.ts → checkout-gift-cards.component.d.ts} +0 -0
- /package/dist/types/modules/checkout/components/{summary/checkout-item-quantity.component.d.ts → checkout-item-quantity.component.d.ts} +0 -0
- /package/dist/types/modules/checkout/components/{summary/checkout-item.component.d.ts → checkout-item.component.d.ts} +0 -0
- /package/dist/types/modules/checkout/components/{summary/checkout-items.component.d.ts → checkout-items.component.d.ts} +0 -0
- /package/dist/types/modules/checkout/components/{summary/checkout-presale-expired.component.d.ts → checkout-presale-expired.component.d.ts} +0 -0
- /package/dist/types/modules/checkout/components/{summary/checkout-promo-code.component.d.ts → checkout-promo-code.component.d.ts} +0 -0
- /package/dist/types/modules/checkout/components/{summary/checkout-tips.component.d.ts → checkout-tips.component.d.ts} +0 -0
- /package/dist/types/modules/checkout/components/{summary/promo-pc-gc.component.d.ts → promo-pc-gc.component.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -228,7 +228,7 @@ Add a product list to any page with a data attribute:
|
|
|
228
228
|
|
|
229
229
|
### Customizing the Cart Button
|
|
230
230
|
|
|
231
|
-
By default, you get a floating cart button. Here's how to customize it:
|
|
231
|
+
By default, you get a floating cart button with badge. Here's how to customize it:
|
|
232
232
|
|
|
233
233
|
#### Option 1: Cart Button in a Specific Container
|
|
234
234
|
|
|
@@ -246,7 +246,56 @@ By default, you get a floating cart button. Here's how to customize it:
|
|
|
246
246
|
></script>
|
|
247
247
|
```
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
**Position Options:**
|
|
250
|
+
|
|
251
|
+
You can control where the cart button is placed relative to a target element:
|
|
252
|
+
|
|
253
|
+
```html
|
|
254
|
+
<!-- Place inside the target (default) -->
|
|
255
|
+
<script data-cart-badge-button="header-cart" ...></script>
|
|
256
|
+
|
|
257
|
+
<!-- Place above the target -->
|
|
258
|
+
<script data-cart-badge-button="above:.header-logo" ...></script>
|
|
259
|
+
|
|
260
|
+
<!-- Place below the target -->
|
|
261
|
+
<script data-cart-badge-button="below:#main-nav" ...></script>
|
|
262
|
+
|
|
263
|
+
<!-- Replace the target -->
|
|
264
|
+
<script data-cart-badge-button="replace:.old-cart" ...></script>
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**ID Auto-Prefixing:**
|
|
268
|
+
|
|
269
|
+
Element IDs are automatically prefixed with `#` if needed:
|
|
270
|
+
|
|
271
|
+
```html
|
|
272
|
+
<!-- These are equivalent: -->
|
|
273
|
+
<script data-cart-button="header-cart" ...></script>
|
|
274
|
+
<script data-cart-button="#header-cart" ...></script>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
#### Option 2: Floating Cart Button (Default)
|
|
278
|
+
|
|
279
|
+
If no cart button attribute is provided, or if the target element is not found, the SDK automatically falls back to a floating cart button (bottom-right corner):
|
|
280
|
+
|
|
281
|
+
```html
|
|
282
|
+
<!-- Empty attribute = floating cart button without badge -->
|
|
283
|
+
<script data-cart-button="" ...></script>
|
|
284
|
+
|
|
285
|
+
<!-- Empty badge attribute = floating cart button with badge -->
|
|
286
|
+
<script data-cart-badge-button="" ...></script>
|
|
287
|
+
|
|
288
|
+
<!-- Or simply omit the attribute for floating button with badge -->
|
|
289
|
+
<script
|
|
290
|
+
data-liquid-commerce-elements
|
|
291
|
+
data-token="YOUR_API_KEY"
|
|
292
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
293
|
+
></script>
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### Option 3: No Cart Button (Manual Control)
|
|
297
|
+
|
|
298
|
+
Hide the cart button completely when you want to manage cart access manually:
|
|
250
299
|
|
|
251
300
|
```html
|
|
252
301
|
<script
|
|
@@ -258,6 +307,8 @@ By default, you get a floating cart button. Here's how to customize it:
|
|
|
258
307
|
></script>
|
|
259
308
|
```
|
|
260
309
|
|
|
310
|
+
**Use case:** When you have a custom cart implementation or want to trigger cart display programmatically using `client.actions.cart.openCart()`
|
|
311
|
+
|
|
261
312
|
### Advanced Auto-Init Features
|
|
262
313
|
|
|
263
314
|
#### Add Product via URL (Marketing Links)
|
|
@@ -357,15 +408,19 @@ Here's every available data attribute:
|
|
|
357
408
|
data-env="production|staging|development|local"
|
|
358
409
|
|
|
359
410
|
<!-- Cart Button -->
|
|
360
|
-
data-cart-button="container-id"
|
|
361
|
-
data-cart-badge-button="container-id"
|
|
362
|
-
data-cart-button-hidden
|
|
411
|
+
data-cart-button="container-id" <!-- Simple cart button (no badge) -->
|
|
412
|
+
data-cart-badge-button="container-id" <!-- Cart button with badge -->
|
|
413
|
+
data-cart-button-hidden <!-- Hide cart button completely -->
|
|
363
414
|
|
|
364
415
|
<!-- Cart Button with Position Prefixes -->
|
|
365
|
-
data-cart-button="above:.logo"
|
|
366
|
-
data-cart-badge-button="below:#header"
|
|
367
|
-
data-cart-button="inside:.nav"
|
|
368
|
-
data-cart-badge-button="replace:.old-cart"
|
|
416
|
+
data-cart-button="above:.logo" <!-- Place above target -->
|
|
417
|
+
data-cart-badge-button="below:#header" <!-- Place below target -->
|
|
418
|
+
data-cart-button="inside:.nav" <!-- Place inside target (default) -->
|
|
419
|
+
data-cart-badge-button="replace:.old-cart" <!-- Replace target -->
|
|
420
|
+
|
|
421
|
+
<!-- Cart Button Floating (empty values) -->
|
|
422
|
+
data-cart-button="" <!-- Floating button without badge -->
|
|
423
|
+
data-cart-badge-button="" <!-- Floating button with badge -->
|
|
369
424
|
|
|
370
425
|
<!-- Products (Method 1: Direct) -->
|
|
371
426
|
data-container-1="div-id"
|
|
@@ -775,16 +830,32 @@ Bind elements to auto-update with cart data:
|
|
|
775
830
|
// Show live subtotal
|
|
776
831
|
client.ui.cartSubtotal('cart-total-display');
|
|
777
832
|
|
|
778
|
-
// Show live item count
|
|
833
|
+
// Show live item count (default behavior: hides when count is 0)
|
|
779
834
|
client.ui.cartItemsCount('cart-badge');
|
|
835
|
+
|
|
836
|
+
// Show live item count (always visible, even when 0)
|
|
837
|
+
client.ui.cartItemsCount('cart-badge', { hideZero: false });
|
|
780
838
|
```
|
|
781
839
|
|
|
840
|
+
**Parameters for `cartItemsCount`:**
|
|
841
|
+
- `elementId` (string) - ID of the element to update
|
|
842
|
+
- `options` (object, optional) - Configuration options:
|
|
843
|
+
- `hideZero` (boolean, default: `true`) - When `true`, element is hidden when cart count is 0. When `false`, element remains visible showing "0".
|
|
844
|
+
|
|
782
845
|
**Example:**
|
|
783
846
|
```html
|
|
784
847
|
<nav>
|
|
785
848
|
<span>Cart: $<span id="cart-total-display">0.00</span></span>
|
|
786
849
|
<span>(<span id="cart-badge">0</span> items)</span>
|
|
787
850
|
</nav>
|
|
851
|
+
|
|
852
|
+
<script>
|
|
853
|
+
// Default behavior - badge hidden when cart is empty
|
|
854
|
+
client.ui.cartItemsCount('cart-badge');
|
|
855
|
+
|
|
856
|
+
// Always show count, even when 0
|
|
857
|
+
client.ui.cartItemsCount('cart-badge', { hideZero: false });
|
|
858
|
+
</script>
|
|
788
859
|
```
|
|
789
860
|
|
|
790
861
|
### Builder Methods (Development Mode)
|
|
@@ -943,13 +1014,13 @@ await actions.cart.applyPromoCode('WELCOME10');
|
|
|
943
1014
|
|
|
944
1015
|
// Listen for promo code feedback
|
|
945
1016
|
window.addEventListener('lce:actions.cart_promo_code_applied', function(event) {
|
|
946
|
-
const {
|
|
1017
|
+
const { discountAmount, newTotal } = event.detail.data;
|
|
947
1018
|
console.log(`✅ Promo applied! Discount: $${discountAmount}, New total: $${newTotal}`);
|
|
948
1019
|
showSavingsMessage(discountAmount);
|
|
949
1020
|
});
|
|
950
1021
|
|
|
951
1022
|
window.addEventListener('lce:actions.cart_promo_code_failed', function(event) {
|
|
952
|
-
const {
|
|
1023
|
+
const { error } = event.detail.data;
|
|
953
1024
|
console.log(`❌ Promo failed:`, error);
|
|
954
1025
|
showErrorMessage('Promo code could not be applied');
|
|
955
1026
|
});
|
|
@@ -1004,27 +1075,27 @@ await actions.checkout.applyGiftCard('GIFT123');
|
|
|
1004
1075
|
|
|
1005
1076
|
// Listen for checkout promo code feedback
|
|
1006
1077
|
window.addEventListener('lce:actions.checkout_promo_code_applied', function(event) {
|
|
1007
|
-
const {
|
|
1078
|
+
const { discountAmount, newTotal } = event.detail.data;
|
|
1008
1079
|
console.log(`✅ Checkout promo applied! Saved: $${discountAmount}`);
|
|
1009
1080
|
updateCheckoutTotal(newTotal);
|
|
1010
1081
|
});
|
|
1011
1082
|
|
|
1012
1083
|
window.addEventListener('lce:actions.checkout_promo_code_failed', function(event) {
|
|
1013
|
-
const {
|
|
1084
|
+
const { error } = event.detail.data;
|
|
1014
1085
|
console.log(`❌ Checkout promo failed:`, error);
|
|
1015
1086
|
showCheckoutError('Promo code could not be applied');
|
|
1016
1087
|
});
|
|
1017
1088
|
|
|
1018
1089
|
// Listen for gift card feedback
|
|
1019
1090
|
window.addEventListener('lce:actions.checkout_gift_card_applied', function(event) {
|
|
1020
|
-
const {
|
|
1091
|
+
const { newTotal } = event.detail.data;
|
|
1021
1092
|
console.log('✅ Gift card applied successfully!');
|
|
1022
1093
|
updateCheckoutTotal(newTotal);
|
|
1023
1094
|
showSuccessMessage('Gift card applied to your order');
|
|
1024
1095
|
});
|
|
1025
1096
|
|
|
1026
1097
|
window.addEventListener('lce:actions.checkout_gift_card_failed', function(event) {
|
|
1027
|
-
const {
|
|
1098
|
+
const { error } = event.detail.data;
|
|
1028
1099
|
console.log(`❌ Gift card failed:`, error);
|
|
1029
1100
|
showCheckoutError('Gift card could not be applied');
|
|
1030
1101
|
});
|
|
@@ -1097,8 +1168,11 @@ window.elements.onAllActions((data, metadata) => {
|
|
|
1097
1168
|
- `lce:actions.checkout_submit_started` - Order submission began
|
|
1098
1169
|
- `lce:actions.checkout_submit_completed` - Order completed successfully
|
|
1099
1170
|
- `lce:actions.checkout_submit_failed` - Order failed
|
|
1100
|
-
- `lce:actions.checkout_customer_information_updated` - Customer info entered
|
|
1101
|
-
- `lce:actions.
|
|
1171
|
+
- `lce:actions.checkout_customer_information_updated` - Customer info entered (returns boolean only, no sensitive data)
|
|
1172
|
+
- `lce:actions.checkout_gift_information_updated` - Gift recipient info entered (returns boolean only, no sensitive data)
|
|
1173
|
+
- `lce:actions.checkout_billing_information_updated` - Billing info entered (returns boolean only, no sensitive data)
|
|
1174
|
+
|
|
1175
|
+
**Security Note:** Form update events return only `boolean: true` to track completion without exposing sensitive customer information (names, emails, phone numbers, addresses, etc.). This protects your customers from malicious scripts and data breaches.
|
|
1102
1176
|
|
|
1103
1177
|
#### Address Events
|
|
1104
1178
|
- `lce:actions.address_updated` - Address information changed
|
|
@@ -1417,12 +1491,12 @@ await client.actions.checkout.removeGiftCard('GIFT-1234-5678-9012');
|
|
|
1417
1491
|
|
|
1418
1492
|
// Listen for gift card events
|
|
1419
1493
|
window.addEventListener('lce:actions.checkout_gift_card_applied', (event) => {
|
|
1420
|
-
const {
|
|
1421
|
-
console.log(`
|
|
1494
|
+
const { newTotal } = event.detail.data;
|
|
1495
|
+
console.log(`Gift card applied! New total: $${newTotal}`);
|
|
1422
1496
|
});
|
|
1423
1497
|
|
|
1424
1498
|
window.addEventListener('lce:actions.checkout_gift_card_failed', (event) => {
|
|
1425
|
-
const {
|
|
1499
|
+
const { error } = event.detail.data;
|
|
1426
1500
|
console.log('Gift card failed:', error);
|
|
1427
1501
|
});
|
|
1428
1502
|
```
|
|
@@ -1443,13 +1517,13 @@ await client.actions.cart.removePromoCode();
|
|
|
1443
1517
|
|
|
1444
1518
|
// Listen for promo events
|
|
1445
1519
|
window.addEventListener('lce:actions.cart_promo_code_applied', (event) => {
|
|
1446
|
-
const {
|
|
1447
|
-
console.log(
|
|
1520
|
+
const { discountAmount, newTotal } = event.detail.data;
|
|
1521
|
+
console.log(`Promo applied! Saved $${discountAmount}! New total: $${newTotal}`);
|
|
1448
1522
|
});
|
|
1449
1523
|
|
|
1450
1524
|
window.addEventListener('lce:actions.cart_promo_code_failed', (event) => {
|
|
1451
|
-
const {
|
|
1452
|
-
console.log('Promo failed:', error
|
|
1525
|
+
const { error } = event.detail.data;
|
|
1526
|
+
console.log('Promo failed:', error);
|
|
1453
1527
|
});
|
|
1454
1528
|
```
|
|
1455
1529
|
|