API Reference
See what are the API is being exposed by the cart library
| Name | Type | Default Value | Description | Example | 
|---|---|---|---|---|
isCartOpen | boolean | false | Indicates whether the cart is open or not. | isCartOpen ? "Yes" : "No" | 
toggleCart | function | - | Toggles the visibility of the shopping cart. | toggleCart(); | 
openCart | function | - | Sets the cart open state to true. | openCart(); | 
closeCart | function | - | Sets the cart open state to false. | closeCart(); | 
cartItems | array | [] | An array of items in the cart. | cartItems.map((item) => ( <div key={item.productId}> <p>{item.name}</p> <p>Quantity: {item.quantity}</p> <p>Price: ${item.price}</p> </div> )) | 
addToCart | function | - | Adds an item to the shopping cart or updates its quantity if already in the cart. | addToCart({ productId: 'product1', name: 'Product 1', quantity: 2, price: 20 }); | 
decreaseItem | function | - | Decreases the quantity of an item in the shopping cart or removes it if the quantity becomes zero. | decreaseItem('product1', 1); | 
removeFromCart | function | - | Removes an item from the shopping cart. | removeFromCart('product1'); | 
clearCart | function | - | Clears all items from the shopping cart. | clearCart(); |