useCartItem
Category:
Cart & Checkout
Composable to manage specific cart item
Types
ts
export function useCartItem(
cartItem: Ref<Schemas["LineItem"]>,
): UseCartItemReturn
ts
export type UseCartItemReturn = {
/**
* Calculated price {number} for the current item
*/
itemRegularPrice: ComputedRef<number | undefined>;
/**
* Calculated price {number} for the current item if list price is set
*/
itemSpecialPrice: ComputedRef<number | undefined>;
/**
* Total price for the current item of given quantity in the cart
*/
itemTotalPrice: ComputedRef<number | undefined>;
/**
* Thumbnail url for the current item's entity
*/
itemImageThumbnailUrl: ComputedRef<string>;
/**
* Options (of variation) for the current item
*/
itemOptions: ComputedRef<Schemas["LineItem"]["payload"]["options"]>;
/**
* Type of the current item: "product" or "promotion"
*/
itemType: ComputedRef<Schemas["LineItem"]["type"] | undefined>;
/**
* Determines if the current item is a product
*/
isProduct: ComputedRef<boolean>;
/**
* Determines if the current item is a promotion
*/
isPromotion: ComputedRef<boolean>;
/**
* Determines if the current item can be removed from cart
*/
isRemovable: ComputedRef<boolean>;
/**
* Determines if the current item's quantity can be changed
*/
isStackable: ComputedRef<boolean>;
/**
* Determines if the current item is a digital product (to download)
*/
isDigital: ComputedRef<boolean>;
/**
* Stock information for the current item
*/
itemStock: ComputedRef<number | undefined>;
/**
* Quantity of the current item in the cart
*/
itemQuantity: ComputedRef<number | undefined>;
/**
* Changes the current item quantity in the cart
*/
changeItemQuantity(quantity: number): Promise<Schemas["Cart"]>;
/**
* Removes the current item from the cart
*/
removeItem(): Promise<Schemas["Cart"]>;
};