getCartItemCount()
Gets the current number of items in the cart.
Signature
const count = window.FairShareSDK.getCartItemCount();
Returns
number — The total item count in the cart.
Example
// Display cart count in header const count = window.FairShareSDK.getCartItemCount(); document.getElementById('cart-badge').textContent = count;
Auto-Updating Display
You can also use an element with id="fluid-cart-count" for automatic updates:
<span id="fluid-cart-count">0</span>
The SDK automatically updates this element when the cart changes.
Related
- getCart — Get full cart object
- getLocalCart — Get cached cart