# Cart

> Cart entity - components, queries, links, and related actions

Your storefront encounters the **Cart** entity when a visitor adds products to their shopping session. A Cart holds summary information such as the total item count and cost breakdowns. Individual line items are represented as separate [CartItem](/frontend/api-reference/entities/cart-item) entities linked from the Cart.

**Entity: Cart**

Components: base, cost

Links:

- ecommerce/cart/cart-items → CartItem (multi)

## Components

### Base

Total item quantity, custom fields, and an optional checkout link.

### CartBase `base`

```ts
import { CartBase } from '@laioutr-core/canonical-types/entity/cart';
```

#### Schema

```json
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"totalQuantity":{"description":"Total number of items in the cart.","type":"number"},"customFields":{"allOf":[{"$ref":"#/definitions/CustomFields"}]},"checkoutLink":{"allOf":[{"$ref":"#/definitions/Link"}]}},"required":["totalQuantity"],"additionalProperties":false,"id":"entity:Cart:base","definitions":{"CustomFields":{"description":"Custom fields are a way for implementations to pass arbitrary data to actions, queries, etc.","title":"CustomFields","id":"CustomFields","type":"object","propertyNames":{"type":"string"},"additionalProperties":{}},"Link":{"description":"A link to an internal or external page. Links can be of different types for different link-targets.","id":"Link","anyOf":[{"$ref":"#/definitions/LinkReference"},{"$ref":"#/definitions/LinkUrl"},{"$ref":"#/definitions/LinkPage"},{"$ref":"#/definitions/LinkAnchor"},{"$ref":"#/definitions/LinkPageType"}]},"LinkReference":{"description":"Link to a entity-detail-page.","id":"LinkReference","type":"object","properties":{"type":{"type":"string","const":"reference"},"query":{"$ref":"#/definitions/__schema0"},"reference":{"type":"object","properties":{"type":{},"slug":{"type":"string"},"id":{"type":"string"}},"required":["type","slug"],"additionalProperties":false}},"required":["type","reference"],"additionalProperties":false},"__schema0":{"type":"object","propertyNames":{"anyOf":[{"type":"string"},{"type":"number"}]},"additionalProperties":{"anyOf":[{"$ref":"#/definitions/__schema1"},{"type":"array","items":{"$ref":"#/definitions/__schema1"}}]}},"__schema1":{"description":"As we use vue-router, we need to adhere to its supported query types: https://router.vuejs.org/api/type-aliases/LocationQueryRaw.html","anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]},"LinkUrl":{"description":"Link to a given url directly.","id":"LinkUrl","type":"object","properties":{"type":{"type":"string","const":"url"},"query":{"$ref":"#/definitions/__schema0"},"href":{"type":"string"},"target":{"type":"string","enum":["_blank"]}},"required":["type","href"],"additionalProperties":false},"LinkPage":{"description":"Link to a specific page by its ID.","id":"LinkPage","type":"object","properties":{"type":{"type":"string","const":"page"},"query":{"$ref":"#/definitions/__schema0"},"page":{"type":"object","properties":{"id":{"type":"string"}},"required":["id"],"additionalProperties":false},"params":{"allOf":[{"$ref":"#/definitions/__schema2"}]}},"required":["type","page"],"additionalProperties":false},"__schema2":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"LinkAnchor":{"description":"Link to an anchor on the current page","id":"LinkAnchor","type":"object","properties":{"type":{"type":"string","const":"anchor"},"query":{"$ref":"#/definitions/__schema0"},"fragment":{"description":"Does _not_ contain the hash (#) prefix. See https://url.spec.whatwg.org/#concept-url-fragment","type":"string"}},"required":["type","fragment"],"additionalProperties":false},"LinkPageType":{"description":"Link to a page of a certain type. It's not guaranteed that a page of this type exists.","id":"LinkPageType","type":"object","properties":{"type":{"type":"string","const":"pageType"},"query":{"$ref":"#/definitions/__schema0"},"pageType":{"type":"string"},"params":{"allOf":[{"$ref":"#/definitions/__schema2"}]},"subject":{"type":"object","properties":{"type":{},"id":{"type":"string"}},"required":["type","id"],"additionalProperties":false}},"required":["type","pageType"],"additionalProperties":false}}}
```

### Cost

Price breakdown for the entire cart: subtotal, total, shipping, duty, and tax information.

### CartCost `cost`

```ts
import { CartCost } from '@laioutr-core/canonical-types/entity/cart';
```

#### Schema

```json
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"subtotal":{"$ref":"#/definitions/Money"},"subtotalIsEstimated":{"description":"Whether the subtotal is estimated.","type":"boolean"},"total":{"$ref":"#/definitions/Money"},"totalIsEstimated":{"description":"Whether the total is estimated.","type":"boolean"},"shipping":{"type":"object","properties":{"total":{"$ref":"#/definitions/Money"},"isEstimated":{"description":"Whether the total shipping cost is estimated.","type":"boolean"}},"required":["total","isEstimated"],"additionalProperties":false},"duty":{"description":"Duty information.","type":"object","properties":{"total":{"$ref":"#/definitions/Money"},"isEstimated":{"description":"Whether the total duty is estimated.","type":"boolean"},"isIncluded":{"description":"Whether duties are included in product-prices.","type":"boolean"}},"required":["total","isEstimated","isIncluded"],"additionalProperties":false},"tax":{"description":"Tax information.","type":"object","properties":{"total":{"$ref":"#/definitions/Money"},"isEstimated":{"description":"Whether the total tax is estimated.","type":"boolean"},"isIncluded":{"description":"Whether taxes are included in product-prices.","type":"boolean"}},"required":["total","isEstimated","isIncluded"],"additionalProperties":false},"taxes":{"description":"Aggregation of taxes applied to the cart-items.","type":"array","items":{"type":"object","properties":{"rate":{"description":"The rate of the tax (e.g. 0.19 for 19% VAT).","type":"number"},"amount":{"$ref":"#/definitions/Money"},"name":{"description":"The name of the tax. This is usually the name of the tax-rate (e.g. \"VAT\").","type":"string"}},"required":["rate","amount"],"additionalProperties":false}}},"required":["subtotal","subtotalIsEstimated","total","totalIsEstimated"],"additionalProperties":false,"id":"entity:Cart:cost","definitions":{"Money":{"description":"A Money object describes a monetary value. You can use e.g. `@screeny05/ts-money` to create and manipulate Money objects more elegantly.","title":"Money","id":"Money","type":"object","properties":{"amount":{"description":"Amount in smallest unit of currency. E.g. cents, pence, etc.","type":"number"},"currency":{"description":"ISO 4217 currency code. E.g. 'USD', 'EUR', 'GBP', etc.","type":"string"}},"required":["amount","currency"],"additionalProperties":false}}}
```

## Queries

- [GetCurrentCartQuery](/frontend/api-reference/ecommerce/queries#cart) - Retrieve the current cart for the customer session.

## Links

- **CartItemsLink** `CartItem` `multi` - All line items in the cart.

## Related actions

- [CartAddItemsAction](/frontend/api-reference/ecommerce/actions#cart) - Add line items to the current cart.
- [CartRemoveItemsAction](/frontend/api-reference/ecommerce/actions#cart) - Remove line items from the cart by their IDs.
- [CartUpdateItemsAction](/frontend/api-reference/ecommerce/actions#cart) - Update quantity or custom fields of existing line items.
- [GetCheckoutUrlAction](/frontend/api-reference/ecommerce/actions#cart) - Get the checkout URL to redirect the customer to the external checkout page.

## Related Entities

- [Product](/frontend/api-reference/entities/product) - Products whose variants can be added to the cart.
- [ProductVariant](/frontend/api-reference/entities/product-variant) - The purchasable SKUs added to the cart as line items.
