CartItem
The CartItem type represents the possible item types within a cart. In summary, its signature and the types used follow this contract:
type CartItem = CartAvailableItem | CartUnavailableItem;Here are the respective types for CartAvailableItem and CartUnavailableItem:
type CartAvailableItem = BaseCartItem & { status: 'available'; price: number;};
type CartUnavailableItem = BaseCartItem & { status: 'unavailable'; price?: number;};BaseCartItem
Both CartAvailableItem and CartUnavailableItem extend BaseCartItem, which has the following structure:
type BaseCartItem = { id: string; originalIndex: number; quantity: number; imageUrl: string; productUrl: string; offerings: Array<Offering>;};The originalIndex property represents the unique position of the item in the cart and is used for operations like removing items via the removeItem function available in useCart and useCartPunchout hooks.
Offering
The Offering type is defined as:
type Offering = { type: string; name: string; id: string;};