web / useCart
Function: useCart() ​
useCart():
object
Defined in: apps/web/composables/useCart/useCart.ts:48
Returns ​
object
UseCartReturn
addItemsToCart() ​
addItemsToCart: (
params
) =>Promise
<boolean
>
Parameters ​
params ​
DoAddItemParams
[]
Returns ​
Promise
<boolean
>
Description ​
Function for adding multiple cart items.
Example ​
addItemsToCart([{
productId: 1,
quantity: 1,
}]);
addToCart() ​
addToCart: (
params
) =>Promise
<boolean
>
Parameters ​
params ​
DoAddItemParams
Returns ​
Promise
<boolean
>
Description ​
Function for adding cart items.
Example ​
addToCart({
productId: 1,
quantity: 1,
});
cartIsEmpty ​
cartIsEmpty:
ComputedRef
<boolean
>
clearCartItems() ​
clearCartItems: () =>
void
Returns ​
void
Description ​
Function for clearing cart items from state.
Example ​
clearCartItems()
data ​
data:
Ref
<Cart
,Cart
>
deleteCart() ​
deleteCart: () =>
Promise
<void
>
Returns ​
Promise
<void
>
Description ​
Function for deleting the cart.
Example ​
await deleteCart()
deleteCartItem() ​
deleteCartItem: (
cartItem
) =>Promise
<Cart
>
Parameters ​
cartItem ​
CartItem
Returns ​
Promise
<Cart
>
Description ​
Function for removing cart items.
Example ​
deleteCartItem({
cartItemId: 1
});
getCart() ​
getCart: () =>
Promise
<void
>
Returns ​
Promise
<void
>
Deprecated ​
Use useFetchSession.fetchSession() instead
lastUpdatedCartItem ​
lastUpdatedCartItem:
Ref
<CartItem
,CartItem
>
loading ​
loading:
Ref
<boolean
,boolean
> =false
setCart() ​
setCart: (
data
) =>void
Parameters ​
data ​
Cart
Returns ​
void
Description ​
Function for setting the cart state.
Example ​
setCart(data)
setCartItemQuantity() ​
setCartItemQuantity: (
params
) =>Promise
<Cart
>
Parameters ​
params ​
SetCartItemQuantityParams
Returns ​
Promise
<Cart
>
Description ​
Function for updating cart item quantity.
Example ​
setCartItemQuantity({
productId: 1,
quantity: 1,
cartItemId: 1,
});
showNetPrices ​
showNetPrices:
ComputedRef
<boolean
>
useAsShippingAddress ​
useAsShippingAddress:
Ref
<boolean
,boolean
> =true
Description ​
Composable for managing cart.
Example ​
const {
data, loading, getCart, setCart, clearCartItems, addToCart, setCartItemQuantity, deleteCartItem
} = useCart();