CartItem

Represents an individual item within a shopping cart.

Entity

Overview

The CartItem entity represents individual products within a customer’s shopping cart. It maintains snapshots of product information and pricing to ensure consistency during the shopping session.

Entity Properties

Name Type Required Description
cartItemIdUUID Required Unique identifier for the cart item
cartIdUUID Required Shopping cart this item belongs to
productIdUUID Required Product being added to cart
skustring Required Product SKU at time of adding to cart
productNamestring Required Product name snapshot at time of adding to cart
productImagestring Optional Product image URL snapshot
quantityinteger Required Quantity of this product in the cart
unitPricedecimal Required Unit price at time of adding to cart
totalPricedecimal Required Total price for this line item (quantity × unit price)
originalPricedecimal Optional Original product price before any discounts
discountAmountdecimal Optional Discount applied to this line item
productVariantobject Optional Product variant details (size, color, etc.)
isAvailableboolean Required Whether the product is still available
notesstring Optional Customer notes for this item
addedAtDateTime Required Date and time when item was added to cart
updatedAtDateTime Optional Date and time when item was last updated

Relationships

  • ShoppingCart: Each cart item belongs to one ShoppingCart (identified by cartId).
  • Product: Each cart item references one Product (identified by productId).

Price Calculations

  • Total Price = Quantity × Unit Price - Discount Amount
  • Savings = Original Price - Unit Price (if applicable)

Examples

  • CartItem #1: iPhone 15 Pro, quantity 1, $999.99 unit price, no discount.
  • CartItem #2: Running Shoes Size 9, quantity 2, $64.99 unit price (was $129.99).
  • CartItem #3: T-Shirt Large/Blue, quantity 3, $19.99 unit price.

Business Rules

  • Quantity must be greater than zero
  • Unit price is captured at time of adding to maintain consistency
  • Product availability is checked when cart is accessed
  • Unavailable items are marked but not automatically removed
  • Total price is recalculated when quantity changes
  • Product snapshots prevent price changes from affecting active carts
  • Maximum quantity limits may apply per product type