@liquidcommerce/elements-sdk 2.5.6-beta.4 → 2.5.7

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
@@ -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 with badge. Here's how to customize it:
231
+ By default, you get a floating cart button. Here's how to customize it:
232
232
 
233
233
  #### Option 1: Cart Button in a Specific Container
234
234
 
@@ -246,56 +246,7 @@ By default, you get a floating cart button with badge. Here's how to customize i
246
246
  ></script>
247
247
  ```
248
248
 
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:
249
+ #### Option 2: No Cart Button (Manual Control)
299
250
 
300
251
  ```html
301
252
  <script
@@ -307,8 +258,6 @@ Hide the cart button completely when you want to manage cart access manually:
307
258
  ></script>
308
259
  ```
309
260
 
310
- **Use case:** When you have a custom cart implementation or want to trigger cart display programmatically using `client.actions.cart.openCart()`
311
-
312
261
  ### Advanced Auto-Init Features
313
262
 
314
263
  #### Add Product via URL (Marketing Links)
@@ -408,19 +357,15 @@ Here's every available data attribute:
408
357
  data-env="production|staging|development|local"
409
358
 
410
359
  <!-- Cart Button -->
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 -->
360
+ data-cart-button="container-id"
361
+ data-cart-badge-button="container-id"
362
+ data-cart-button-hidden
414
363
 
415
364
  <!-- Cart Button with Position Prefixes -->
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 -->
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"
424
369
 
425
370
  <!-- Products (Method 1: Direct) -->
426
371
  data-container-1="div-id"
@@ -830,32 +775,16 @@ Bind elements to auto-update with cart data:
830
775
  // Show live subtotal
831
776
  client.ui.cartSubtotal('cart-total-display');
832
777
 
833
- // Show live item count (default behavior: hides when count is 0)
778
+ // Show live item count
834
779
  client.ui.cartItemsCount('cart-badge');
835
-
836
- // Show live item count (always visible, even when 0)
837
- client.ui.cartItemsCount('cart-badge', { hideZero: false });
838
780
  ```
839
781
 
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
-
845
782
  **Example:**
846
783
  ```html
847
784
  <nav>
848
785
  <span>Cart: $<span id="cart-total-display">0.00</span></span>
849
786
  <span>(<span id="cart-badge">0</span> items)</span>
850
787
  </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>
859
788
  ```
860
789
 
861
790
  ### Builder Methods (Development Mode)