> ## Documentation Index
> Fetch the complete documentation index at: https://docs-loja.usecorvex.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Cart

> Referência de StorefrontCart e StorefrontCartItem — contrato público 2026-08.

Contrato canônico resumido: [Cart Contract](https://docs-loja.usecorvex.com.br/reference/contracts/cart.md).

Fonte normativa: `StorefrontCart`, `StorefrontCartItem` em `@corvex/theme-sdk` types.

***

## StorefrontCart

| Campo | Tipo | Nullable | Descrição |
| - | - | - | - |
| `id` | `string` | não | ID do carrinho |
| `checkoutId` | `string` | não | ID checkout |
| `checkoutUrl` | `string` | sim | URL de checkout. Pode faltar se a resposta não trouxer |
| `storeId` | `string` | não | Loja |
| `token` | `string` | não | Token |
| `currency` | `string` | não | Moeda |
| `items` | `StorefrontCartItem[]` | não | Linhas |
| `itemsCount` | `number` | não | Contagem |
| `itemCount` | `number` | não | Contagem (alias) |
| `subtotalPrice` | `number` | não | Subtotal |
| `totalPrice` | `number` | não | Total |
| `total` | `number` | não | Total |
| `totalDiscount` | `number` | não | Desconto |
| `requiresShipping` | `boolean` | não | Envio |
| `customer` | `Record<string, unknown>` | sim | Cliente |
| `redirect` | `Record<string, unknown>` | sim | Redirect checkout |
| `metadata` | `Record<string, unknown>` | sim | Metadados |
| `createdAt` | `string` | sim | ISO |
| `updatedAt` | `string` | sim | ISO |

***

## StorefrontCartItem

| Campo | Tipo | Nullable | Descrição |
| - | - | - | - |
| `id` | `string` | não | ID da linha |
| `productId` | `string` | não | Produto |
| `productVariantId` | `string` | sim | Variante |
| `title` | `string` | não | Título |
| `name` | `string` | não | Nome |
| `quantity` | `number` | não | Quantidade |
| `unitPrice` | `number` | não | Preço unitário |
| `linePrice` | `number` | não | Total da linha |
| `price` | `number` | não | Preço |
| `image` | `string` | sim | URL imagem |
| `sku` | `string` | sim | SKU |
| `requiresShipping` | `boolean` | não | Envio |
| `unitPriceMoney` | `Money` | não | Preço unitário formatável |
| `linePriceMoney` | `Money` | não | Total da linha formatável |

`unitPrice` e `linePrice` são números. A moeda do carrinho é `currency`. Cupom não é campo deste objeto. Se a API já calculou desconto, ele está em `totalDiscount`. Ações: [Cart actions](https://docs-loja.usecorvex.com.br/data/actions/cart.md).

Lista pública: **`items`** (não `lines`). Use `item.id` para atualizar ou remover, não `productId`.

***

## Hook `useCorvexCart`

```jsx theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { useCorvexCart } from '@corvex/theme-sdk';

const { items, itemCount, addItem, updateQuantity, removeItem, goToCheckout } =
  useCorvexCart();
```

***

## Página de carrinho

```jsx theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { usePage } from '@corvex/theme-sdk';

const { cart } = usePage('cart');

return (
  <ul>
    {cart.items.map((item) => (
      <li key={item.id}>
        {item.title} × {item.quantity}
      </li>
    ))}
  </ul>
);
```

***

## Tipos relacionados

* [Cart actions](https://docs-loja.usecorvex.com.br/data/actions/cart.md)
* [Product](https://docs-loja.usecorvex.com.br/data/resources/product.md)
* [Product Variant](https://docs-loja.usecorvex.com.br/data/resources/product-variant.md)
* [Cart Drawer Cookbook](https://docs-loja.usecorvex.com.br/cookbook/cart-drawer.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.