@active-reach/web-sdk 1.27.3 → 1.28.0

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
@@ -477,27 +477,38 @@ Drop an empty element wherever you want the card to appear. Its `data-aegis-slot
477
477
 
478
478
  No per-slot script and no manual registration — `runtime.initialize()` scans for every `[data-aegis-slot]` element and fills it. It re-scans on each SSE/poll refresh and skips slots it has already filled.
479
479
 
480
- ### Cart recovery (platform auto-detection)
480
+ ### Cart state — one store, fed the CEP-standard way
481
481
 
482
- For cart-abandonment campaigns the widget subsystem auto-detects cart data:
482
+ Every cart-reactive surface — the **free-delivery progress card**, the standalone
483
+ **progress bar**, cart-value **targeting rules**, and **cart-recovery** widgets —
484
+ reads ONE cart store. You feed it the same way you'd feed WebEngage/CleverTap: by
485
+ firing the **ecommerce events** you already fire. The SDK derives the live cart
486
+ from them; no separate cart call.
487
+
488
+ ```typescript
489
+ // 1) Wire the ecommerce tracker into the cart store, once at boot:
490
+ runtime.bindEcommerce(aegis.ecommerce);
491
+
492
+ // 2) Fire ecommerce events as the shopper shops — the cart is derived from these:
493
+ aegis.ecommerce.addToCart({ product_id: 'p1', name: 'Cap', price: 499, quantity: 1 });
494
+ aegis.ecommerce.cartViewed({ value: 998, currency: 'INR', products: [/* … */] }); // authoritative snapshot
495
+ ```
496
+
497
+ **Platform installs need no event wiring** — the plugin does it for you. Carts are
498
+ detected and fed into the same store automatically:
483
499
 
484
500
  | Platform | Detection method | Setup |
485
501
  |----------|-----------------|-------|
486
- | **Shopify** | `window.Shopify.checkout` / DOM `#cart-json` | None |
487
- | **WooCommerce** | `window.aegis_cart` (injected by plugin) | Install WP plugin |
488
- | **Magento 2** | `localStorage['mage-cache-storage']` | None |
489
- | **Custom / Mobile** | Manual | Call `setCartData()` |
502
+ | **Shopify** | `/cart.js` poll + `cart:updated` (plugin) | Install the Shopify app |
503
+ | **WooCommerce** | `aegis_cart` + WC Store API on cart events (plugin) | Install the WP plugin |
504
+ | **Magento 2** | `localStorage['mage-cache-storage']` | Install the extension |
505
+ | **Custom / headless / mobile** | Fire `aegis.ecommerce.*` (above) | `runtime.bindEcommerce(...)` |
506
+
507
+ **Escape hatch** — a headless host that doesn't emit ecommerce events can push the
508
+ cart directly; this writes the same one store:
490
509
 
491
510
  ```typescript
492
- // Custom platforms only — reach the widget subsystem via runtime.widgets
493
- runtime.widgets.setCartData({
494
- cart_id: 'cart_123',
495
- cart_total: 149.99,
496
- cart_currency: 'INR',
497
- cart_items: [
498
- { product_id: 'prod_456', product_name: 'Premium Widget', quantity: 2, price: 74.99 }
499
- ],
500
- });
511
+ runtime.setCartState({ total: 149.99, itemCount: 2, currency: 'INR' });
501
512
  ```
502
513
 
503
514
  ---