use-shopping-cart

API

API

cartDetails

Cart details is an object with skus of the items in the cart as keys and details of the items as the value, for example:

{}

As you add more items to the cartItem array, cart details will update with quantity and total amount of that particular item.


cartCount

Total number of items in the cart


totalPrice

Total price of all products in cart

0

0

$0.00

handleCartClick, handleCloseCart and shouldDisplayCart

These three API items provide basic state management for your cart. The cart state is stored in the shouldDisplayCart variable. The two functions can be used to update this state.

shouldDisplayCart: Boolean value which can be used to handle the cart's displayed or undisplayed state.

handleCartClick: Function which toggles the displayed state for the cart between true and false, updates shouldDisplayCart.

handleCloseCart: Function which sets the displayed cart state to false, updates shouldDisplayCart.

Edit this page on GitHub