# `PhoenixKitEcommerce.Cart`
[🔗](https://github.com/BeamLabEU/phoenix_kit_ecommerce/blob/0.1.15/lib/phoenix_kit_ecommerce/schemas/cart.ex#L1)

Shopping cart schema with support for guest and authenticated users.

## Status Lifecycle

- `active` - Cart is active and can be modified
- `merged` - Guest cart was merged into user cart after login
- `converted` - Cart was converted to an order
- `abandoned` - Cart was marked as abandoned (no activity)
- `expired` - Cart expired (past expires_at)

## Identity

Each cart has either `user_uuid` (for authenticated users) or `session_id` (for guests).
Guest carts have an `expires_at` timestamp (30 days by default).
When a guest logs in, their cart is either converted to a user cart or merged
with an existing user cart.

# `t`

```elixir
@type t() :: %PhoenixKitEcommerce.Cart{
  __meta__: term(),
  converted_at: term(),
  currency: term(),
  discount_amount: term(),
  discount_code: term(),
  expires_at: term(),
  inserted_at: term(),
  items: term(),
  items_count: term(),
  merged_into_cart_uuid: term(),
  metadata: term(),
  payment_option_uuid: term(),
  session_id: term(),
  shipping_amount: term(),
  shipping_country: term(),
  shipping_method: term(),
  shipping_method_uuid: term(),
  status: term(),
  subtotal: term(),
  tax_amount: term(),
  total: term(),
  total_weight_grams: term(),
  updated_at: term(),
  user: term(),
  user_uuid: term(),
  uuid: term()
}
```

A shopping cart row.

# `active?`

Returns true if cart is active.

# `changeset`

Changeset for cart creation and updates.

# `convertible?`

Returns true if cart can be converted to order.

# `empty?`

Returns true if cart is empty.

# `expired?`

Returns true if cart has expired.

# `guest?`

Returns true if cart is a guest cart (no user_uuid).

# `payment_changeset`

Changeset for setting payment option.

# `shipping_changeset`

Changeset for setting shipping.

# `status_changeset`

Changeset for status transitions.

# `statuses`

Returns list of valid status values.

# `totals_changeset`

Changeset for updating cart totals.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
