@liquidcommerce/elements-sdk 2.3.0 → 2.4.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 CHANGED
@@ -683,7 +683,8 @@ const actions = window.elements.actions;
683
683
  ```js
684
684
  // Get product details
685
685
  const product = actions.product.getDetails('product-123');
686
- console.log(product.productName, product.price, product.isAvailable);
686
+ console.log(product.name, product.brand, product.region, product.variety);
687
+ console.log(product.priceInfo, product.description, product.tastingNotes);
687
688
  ```
688
689
 
689
690
  ### Address Actions
@@ -784,7 +785,7 @@ await actions.cart.removePromoCode();
784
785
 
785
786
  // Get cart details
786
787
  const cart = actions.cart.getDetails();
787
- console.log(cart.total, cart.items.length);
788
+ console.log(cart.itemCount, cart.amounts.total, cart.amounts.giftCardTotal);
788
789
 
789
790
  // Reset cart
790
791
  await actions.cart.resetCart();
@@ -856,12 +857,10 @@ window.addEventListener('lce:actions.checkout_gift_card_failed', function(event)
856
857
 
857
858
  // Get checkout details (safe, non-sensitive data only)
858
859
  const checkout = actions.checkout.getDetails();
859
- console.log('Total:', checkout.amounts.total);
860
- console.log('Items:', checkout.itemCount);
861
- console.log('Is gift:', checkout.isGift);
862
- console.log('Has age verification:', checkout.hasAgeVerify);
863
- console.log('Has promo code:', checkout.hasPromoCode);
864
- console.log('Has gift cards:', checkout.hasGiftCards);
860
+ console.log(checkout.itemCount, checkout.amounts.total, checkout.isGift);
861
+ console.log(checkout.hasAgeVerify, checkout.hasPromoCode, checkout.hasGiftCards);
862
+ console.log(checkout.acceptedAccountCreation, checkout.billingSameAsShipping);
863
+ console.log(checkout.marketingPreferences);
865
864
 
866
865
  // Configure checkout options
867
866
  await actions.checkout.toggleBillingSameAsShipping(true);
@@ -877,13 +876,14 @@ The SDK emits real-time events for all user interactions. Listen to these events
877
876
  ```js
878
877
  // Listen for specific events
879
878
  window.addEventListener('lce:actions.product_add_to_cart', function(event) {
880
- const product = event.detail.data;
881
- console.log('Added to cart:', product.productName);
879
+ const data = event.detail.data;
880
+ console.log('Added to cart:', data.identifier);
882
881
 
883
882
  // Your custom logic here
884
883
  analytics.track('Product Added', {
885
- product: product.productName,
886
- price: product.price
884
+ identifier: data.identifier,
885
+ quantity: data.quantity,
886
+ upc: data.upc
887
887
  });
888
888
  });
889
889
 
@@ -900,7 +900,7 @@ window.elements.onAllActions((data, metadata) => {
900
900
  ### Available Events
901
901
 
902
902
  #### Product Events
903
- - `lce:actions.product_loaded` - Product component loaded
903
+ - `lce:actions.product_loaded` - Product component loaded with comprehensive product details (region, country, abv, proof, age, variety, vintage, descriptions, tasting notes)
904
904
  - `lce:actions.product_add_to_cart` - Item added to cart
905
905
  - `lce:actions.product_quantity_increase` - Quantity increased
906
906
  - `lce:actions.product_quantity_decrease` - Quantity decreased
@@ -908,6 +908,7 @@ window.elements.onAllActions((data, metadata) => {
908
908
  - `lce:actions.product_fulfillment_type_changed` - Delivery method changed
909
909
 
910
910
  #### Cart Events
911
+ - `lce:actions.cart_loaded` - Cart data loaded with complete cart information (itemCount, all amounts including giftCardTotal, detailed item data)
911
912
  - `lce:actions.cart_opened` - Cart displayed
912
913
  - `lce:actions.cart_closed` - Cart hidden
913
914
  - `lce:actions.cart_updated` - Cart contents changed
@@ -916,6 +917,7 @@ window.elements.onAllActions((data, metadata) => {
916
917
  - `lce:actions.cart_reset` - Cart cleared
917
918
 
918
919
  #### Checkout Events
920
+ - `lce:actions.checkout_loaded` - Checkout data loaded with comprehensive details (acceptedAccountCreation, hasSubstitutionPolicy, billingSameAsShipping, marketing preferences, detailed items)
919
921
  - `lce:actions.checkout_opened` - Checkout started
920
922
  - `lce:actions.checkout_closed` - Checkout abandoned
921
923
  - `lce:actions.checkout_submit_started` - Order submission began
@@ -928,7 +930,7 @@ window.elements.onAllActions((data, metadata) => {
928
930
  - `lce:actions.address_updated` - Address information changed
929
931
  - `lce:actions.address_cleared` - Address removed
930
932
 
931
- See [`docs/EVENTS.md`](docs/EVENTS.md) for complete event reference with implementation examples.
933
+ See [`docs/EVENTS.md`](docs/EVENTS.md) for complete event reference with all available fields and implementation examples.
932
934
 
933
935
  ## 🎨 Themes & Customization
934
936
 
@@ -1376,11 +1378,12 @@ The SDK uses a centralized store for all state management. Access state data via
1376
1378
  ```js
1377
1379
  // Get current cart state
1378
1380
  const cart = await client.actions.cart.getDetails();
1379
- console.log(cart.items, cart.subtotal, cart.itemCount);
1381
+ console.log(cart.itemCount, cart.amounts.total, cart.amounts.giftCardTotal);
1380
1382
 
1381
1383
  // Get current checkout state
1382
1384
  const checkout = await client.actions.checkout.getDetails();
1383
- console.log(checkout.total, checkout.customerInfo, checkout.isGift);
1385
+ console.log(checkout.amounts.total, checkout.isGift, checkout.acceptedAccountCreation);
1386
+ console.log(checkout.billingSameAsShipping, checkout.marketingPreferences);
1384
1387
 
1385
1388
  // Get current address
1386
1389
  const address = await client.actions.address.getDetails();
@@ -1388,7 +1391,8 @@ console.log(address.formattedAddress, address.coordinates);
1388
1391
 
1389
1392
  // Get product details
1390
1393
  const product = await client.actions.product.getDetails('00619947000020');
1391
- console.log(product.name, product.price, product.variants);
1394
+ console.log(product.name, product.region, product.variety, product.vintage);
1395
+ console.log(product.description, product.tastingNotes);
1392
1396
  ```
1393
1397
 
1394
1398
  **State is persistent:** Cart and address data persist across page reloads using localStorage.
@@ -1400,8 +1404,8 @@ All SDK interactions emit events through a centralized event system:
1400
1404
  ```js
1401
1405
  // Subscribe to specific event
1402
1406
  window.addEventListener('lce:actions.cart_updated', (event) => {
1403
- const cartData = event.detail.data;
1404
- console.log('Cart changed:', cartData);
1407
+ const { previous, current } = event.detail.data;
1408
+ console.log('Cart changed from', previous.amounts.total, 'to', current.amounts.total);
1405
1409
  });
1406
1410
 
1407
1411
  // Subscribe to all action events
@@ -2074,7 +2078,7 @@ await client.actions.cart.addProduct([...]);
2074
2078
  // ❌ Don't repeatedly fetch the same data
2075
2079
  async function showCartTotal() {
2076
2080
  const cart = await client.actions.cart.getDetails();
2077
- return cart.total;
2081
+ return cart.amounts.total;
2078
2082
  }
2079
2083
 
2080
2084
  // ✅ Use UI helpers that auto-update
@@ -2084,7 +2088,7 @@ client.ui.cartItemsCount('cart-count-display');
2084
2088
  // Or cache and listen to updates
2085
2089
  let cachedCart = await client.actions.cart.getDetails();
2086
2090
  window.addEventListener('lce:actions.cart_updated', (event) => {
2087
- cachedCart = event.detail.data;
2091
+ cachedCart = event.detail.data.current;
2088
2092
  });
2089
2093
  ```
2090
2094