---
title: cart - Storefront API
description: |-
  Returns a [`Cart`](/docs/api/storefront/2026-07/objects/Cart) by
  its ID. The cart contains the merchandise lines a buyer intends to purchase,
  along with estimated costs, applied discounts, gift cards, and delivery options.

  Use the [`checkoutUrl`](https://shopify.dev/docs/api/storefront/latest/queries/cart#returns-Cart.fields.checkoutUrl) field to redirect buyers to Shopify's web checkout when they're ready to
  complete their purchase. For more information, refer to [Manage a cart with the Storefront API](https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/cart/manage).
api_version: 2026-07
source_url:
  html: https://shopify.dev/docs/api/storefront/latest/queries/Cart
  md: https://shopify.dev/docs/api/storefront/latest/queries/Cart.md
---

# cart

query

Returns a [`Cart`](https://shopify.dev/docs/api/storefront/2026-07/objects/Cart) by its ID. The cart contains the merchandise lines a buyer intends to purchase, along with estimated costs, applied discounts, gift cards, and delivery options.

Use the [`checkoutUrl`](https://shopify.dev/docs/api/storefront/latest/queries/cart#returns-Cart.fields.checkoutUrl) field to redirect buyers to Shopify's web checkout when they're ready to complete their purchase. For more information, refer to [Manage a cart with the Storefront API](https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/cart/manage).

## Arguments

* id

  [ID!](https://shopify.dev/docs/api/storefront/latest/scalars/ID)

  required

  The ID of the cart.

***

## Possible returns

* Cart

  [Cart](https://shopify.dev/docs/api/storefront/latest/objects/Cart)

  A cart represents the merchandise that a buyer intends to purchase, and the estimated cost associated with the cart, throughout a customer's session.

  Use the [`checkoutUrl`](https://shopify.dev/docs/api/storefront/2026-07/objects/Cart#field-checkoutUrl) field to direct buyers to Shopify's web checkout to complete their purchase.

  Learn more about [interacting with carts](https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/cart/manage).

  * applied​Gift​Cards

    [\[Applied​Gift​Card!\]!](https://shopify.dev/docs/api/storefront/latest/objects/AppliedGiftCard)

    non-null

    The gift cards that have been applied to the cart.

  * attribute

    [Attribute](https://shopify.dev/docs/api/storefront/latest/objects/Attribute)

    An attribute associated with the cart.

    * key

      [String!](https://shopify.dev/docs/api/storefront/latest/scalars/String)

      required

      ### Arguments

      The key of the attribute.

    ***

  * attributes

    [\[Attribute!\]!](https://shopify.dev/docs/api/storefront/latest/objects/Attribute)

    non-null

    The attributes associated with the cart. Attributes are represented as key-value pairs.

  * buyer​Identity

    [Cart​Buyer​Identity!](https://shopify.dev/docs/api/storefront/latest/objects/CartBuyerIdentity)

    non-null

    Information about the buyer that's interacting with the cart.

  * checkout​Url

    [URL!](https://shopify.dev/docs/api/storefront/latest/scalars/URL)

    non-null

    The URL of the checkout for the cart.

  * cost

    [Cart​Cost!](https://shopify.dev/docs/api/storefront/latest/objects/CartCost)

    non-null

    The estimated costs that the buyer will pay at checkout. The costs are subject to change and changes will be reflected at checkout. The `cost` field uses the `buyerIdentity` field to determine [international pricing](https://shopify.dev/custom-storefronts/internationalization/international-pricing).

  * created​At

    [Date​Time!](https://shopify.dev/docs/api/storefront/latest/scalars/DateTime)

    non-null

    The date and time when the cart was created.

  * delivery

    [Cart​Delivery!](https://shopify.dev/docs/api/storefront/latest/objects/CartDelivery)

    non-null

    The delivery properties of the cart.

  * delivery​Groups

    [Cart​Delivery​Group​Connection!](https://shopify.dev/docs/api/storefront/latest/connections/CartDeliveryGroupConnection)

    non-null

    The delivery groups available for the cart, based on the buyer identity default delivery address preference or the default address of the logged-in customer.

    * after

      [String](https://shopify.dev/docs/api/storefront/latest/scalars/String)

      ### Arguments

      Returns the elements that come after the specified cursor.

    * before

      [String](https://shopify.dev/docs/api/storefront/latest/scalars/String)

      Returns the elements that come before the specified cursor.

    * first

      [Int](https://shopify.dev/docs/api/storefront/latest/scalars/Int)

      Returns up to the first `n` elements from the list.

    * last

      [Int](https://shopify.dev/docs/api/storefront/latest/scalars/Int)

      Returns up to the last `n` elements from the list.

    * reverse

      [Boolean](https://shopify.dev/docs/api/storefront/latest/scalars/Boolean)

      Default:false

      Reverse the order of the underlying list.

    * with​Carrier​Rates

      [Boolean](https://shopify.dev/docs/api/storefront/latest/scalars/Boolean)

      Default:false

      Whether to include [carrier-calculated delivery rates](https://help.shopify.com/en/manual/shipping/setting-up-and-managing-your-shipping/enabling-shipping-carriers) in the response.

      By default, only static shipping rates are returned. This argument requires mandatory usage of the [`@defer` directive](https://shopify.dev/docs/api/storefront#directives).

      For more information, refer to [fetching carrier-calculated rates for the cart using `@defer`](https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/defer#fetching-carrier-calculated-rates-for-the-cart-using-defer).

    ***

  * discount​Applications

    [\[Base​Cart​Discount​Application!\]!](https://shopify.dev/docs/api/storefront/latest/interfaces/BaseCartDiscountApplication)

    non-null

    The discount applications applied to the cart.

  * discount​Codes

    [\[Cart​Discount​Code!\]!](https://shopify.dev/docs/api/storefront/latest/objects/CartDiscountCode)

    non-null

    The case-insensitive discount codes that the customer added at checkout.

  * id

    [ID!](https://shopify.dev/docs/api/storefront/latest/scalars/ID)

    non-null

    A globally-unique ID.

  * lines

    [Base​Cart​Line​Connection!](https://shopify.dev/docs/api/storefront/latest/connections/BaseCartLineConnection)

    non-null

    A list of lines containing information about the items the customer intends to purchase.

    * after

      [String](https://shopify.dev/docs/api/storefront/latest/scalars/String)

      ### Arguments

      Returns the elements that come after the specified cursor.

    * before

      [String](https://shopify.dev/docs/api/storefront/latest/scalars/String)

      Returns the elements that come before the specified cursor.

    * first

      [Int](https://shopify.dev/docs/api/storefront/latest/scalars/Int)

      Returns up to the first `n` elements from the list.

    * last

      [Int](https://shopify.dev/docs/api/storefront/latest/scalars/Int)

      Returns up to the last `n` elements from the list.

    * reverse

      [Boolean](https://shopify.dev/docs/api/storefront/latest/scalars/Boolean)

      Default:false

      Reverse the order of the underlying list.

    ***

  * metafield

    [Metafield](https://shopify.dev/docs/api/storefront/latest/objects/Metafield)

    Token access required

    A [custom field](https://shopify.dev/docs/apps/build/custom-data), including its `namespace` and `key`, that's associated with a Shopify resource for the purposes of adding and storing additional information.

    * key

      [String!](https://shopify.dev/docs/api/storefront/latest/scalars/String)

      required

      ### Arguments

      The identifier for the metafield.

    * namespace

      [String](https://shopify.dev/docs/api/storefront/latest/scalars/String)

      The container the metafield belongs to. If omitted, the app-reserved namespace will be used.

    ***

  * metafields

    [\[Metafield\]!](https://shopify.dev/docs/api/storefront/latest/objects/Metafield)

    non-null Token access required

    A list of [custom fields](https://shopify.dev/docs/apps/build/custom-data) that a merchant associates with a Shopify resource.

    * identifiers

      [\[Has​Metafields​Identifier!\]!](https://shopify.dev/docs/api/storefront/latest/input-objects/HasMetafieldsIdentifier)

      required

      ### Arguments

      The list of metafields to retrieve by namespace and key.

      The input must not contain more than `250` values.

    ***

  * note

    [String](https://shopify.dev/docs/api/storefront/latest/scalars/String)

    A note that's associated with the cart. For example, the note can be a personalized message to the buyer.

  * total​Quantity

    [Int!](https://shopify.dev/docs/api/storefront/latest/scalars/Int)

    non-null

    The total number of items in the cart.

  * updated​At

    [Date​Time!](https://shopify.dev/docs/api/storefront/latest/scalars/DateTime)

    non-null

    The date and time when the cart was updated.

  * discount​Allocations

    [\[Cart​Discount​Allocation!\]!](https://shopify.dev/docs/api/storefront/latest/interfaces/CartDiscountAllocation)

    non-nullDeprecated

  * estimated​Cost

    [Cart​Estimated​Cost!](https://shopify.dev/docs/api/storefront/latest/objects/CartEstimatedCost)

    non-nullDeprecated

***

## Examples

* ### cart reference