getLocalCart()
Gets the cart from local storage without making an API call.
Signature
const cart = window.FairShareSDK.getLocalCart();
Returns
Cart | null — The cached cart object, or null if no cart exists in local storage.
Example
// Check local cart before making API call const localCart = window.FairShareSDK.getLocalCart(); if (localCart) { console.log('Cached cart has', localCart.items.length, 'items'); } else { console.log('No cart in cache, fetching from API...'); const cart = await window.FairShareSDK.getCart(); }
Related
- getCart — Fetch cart from API
- getCartItemCount — Get total item count