CartItem (v1.0.0)

Represents an individual item within a shopping cart.

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

NameTypeRequiredDescription
cartItemIdUUIDRequiredUnique identifier for the cart item
cartIdUUIDRequiredShopping cart this item belongs to
productIdUUIDRequiredProduct being added to cart
skustringRequiredProduct SKU at time of adding to cart
productNamestringRequiredProduct name snapshot at time of adding to cart
productImagestringOptionalProduct image URL snapshot
quantityintegerRequiredQuantity of this product in the cart
unitPricedecimalRequiredUnit price at time of adding to cart
totalPricedecimalRequiredTotal price for this line item (quantity × unit price)
originalPricedecimalOptionalOriginal product price before any discounts
discountAmountdecimalOptionalDiscount applied to this line item
productVariantobjectOptionalProduct variant details (size, color, etc.)
isAvailablebooleanRequiredWhether the product is still available
notesstringOptionalCustomer notes for this item
addedAtDateTimeRequiredDate and time when item was added to cart
updatedAtDateTimeOptionalDate 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