Skip to main content
object

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 field to direct buyers to Shopify's web checkout to complete their purchase.

Learn more about interacting with carts.

•[AppliedGiftCard!]!
non-null

The gift cards that have been applied to the cart.

•Attribute

An attribute associated with the cart.

Arguments

•String!
required

The key of the attribute.


•[Attribute!]!
non-null

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

•CartBuyerIdentity!
non-null

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

•URL!
non-null

The URL of the checkout for the cart.

•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.

•DateTime!
non-null

The date and time when the cart was created.

•CartDelivery!
non-null

The delivery properties of the cart.

•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.

Arguments

•Int

Returns up to the first n elements from the list.

•String

Returns the elements that come after the specified cursor.

•Int

Returns up to the last n elements from the list.

•String

Returns the elements that come before the specified cursor.

•Boolean
Default:false

Reverse the order of the underlying list.

•Boolean
Default:false

Whether to include carrier-calculated delivery rates in the response.

By default, only static shipping rates are returned. This argument requires mandatory usage of the @defer directive.

For more information, refer to fetching carrier-calculated rates for the cart using @defer.


•[CartDiscountAllocation!]!
non-null

The discounts that have been applied to the entire cart.

•[CartDiscountCode!]!
non-null

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

•ID!
non-null

A globally-unique ID.

•BaseCartLineConnection!
non-null

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

Arguments

•Int

Returns up to the first n elements from the list.

•String

Returns the elements that come after the specified cursor.

•Int

Returns up to the last n elements from the list.

•String

Returns the elements that come before the specified cursor.

•Boolean
Default:false

Reverse the order of the underlying list.


•Metafield

A custom field, including its namespace and key, that's associated with a Shopify resource for the purposes of adding and storing additional information.

Arguments

•String

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

•String!
required

The identifier for the metafield.


•[Metafield]!
non-null

A list of custom fields that a merchant associates with a Shopify resource.

Arguments

•[HasMetafieldsIdentifier!]!
required

The list of metafields to retrieve by namespace and key.

The input must not contain more than 250 values.


•String

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

•Int!
non-null

The total number of items in the cart.

•DateTime!
non-null

The date and time when the cart was updated.

•CartEstimatedCost!
non-nullDeprecated

Was this section helpful?

•query

Returns a 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 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.

Arguments

•ID!
required

The ID of the cart.



Was this section helpful?

•mutation

Updates the attributes on a Cart. Attributes are custom key-value pairs that store additional information, such as gift messages, special instructions, or order notes.

Arguments

•[AttributeInput!]!
required

An array of key-value pairs that contains additional information about the cart.

The input must not contain more than 250 values.

•ID!
required

The ID of the cart.


•mutation

Updates the buyer identity on a Cart, including contact information, location, and checkout preferences. The buyer's country determines international pricing and should match their shipping address.

Use this mutation to associate a logged-in customer via access token, set a B2B company location, or configure checkout preferences like delivery method. Preferences prefill checkout fields but don't sync back to the cart if overwritten at checkout.

Arguments

•ID!
required

The ID of the cart.

•CartBuyerIdentityInput!
required

The customer associated with the cart. Used to determine international pricing. Buyer identity should match the customer's shipping address.


•mutation

Creates a new Cart for a buyer session. You can optionally initialize the cart with merchandise lines, discount codes, gift card codes, buyer identity for international pricing, and custom attributes.

The returned cart includes a checkoutUrl that directs the buyer to complete their purchase.

Arguments

•CartInput

The fields used to create a cart.


•mutation

Adds delivery addresses to a Cart. A cart can have up to 20 delivery addresses. One address can be marked as selected for checkout, and addresses can optionally be marked as one-time use so they aren't saved to the customer's account.

Arguments

•ID!
required

The ID of the cart.

•[CartSelectableAddressInput!]!
required

A list of delivery addresses to add to the cart.

The input must not contain more than 250 values.


•mutation

Removes delivery addresses from a Cart by their IDs, allowing batch removal in a single request.

Arguments

•ID!
required

The ID of the cart.

•[ID!]!
required

A list of delivery addresses by handle to remove from the cart.

The input must not contain more than 250 values.


•mutation

Replaces all delivery addresses on a Cart with a new set of addresses in a single operation. Unlike cartDeliveryAddressesUpdate, which modifies existing addresses, this mutation removes all current addresses and sets the provided list as the new delivery addresses.

One address can be marked as selected, and each address can be flagged for one-time use or configured with a specific validation strategy.

Arguments

•ID!
required

The ID of the cart.

•[CartSelectableAddressInput!]!
required

A list of delivery addresses to replace on the cart.

The input must not contain more than 250 values.


•mutation

Updates one or more delivery addresses on a Cart. Each address can be modified to change its details, set it as the pre-selected address for checkout, or mark it for one-time use so it isn't saved to the customer's account.

Arguments

•ID!
required

The ID of the cart.

•[CartSelectableAddressUpdateInput!]!
required

The delivery addresses to update.

The input must not contain more than 250 values.


•mutation

Updates the discount codes applied to a Cart. This mutation replaces all existing discount codes with the provided list, so pass an empty array to remove all codes. Discount codes are case-insensitive.

After updating, check each CartDiscountCode in the cart's discountCodes field to see whether the code is applicable to the cart's current contents.

Arguments

•ID!
required

The ID of the cart.

•[String!]!
required

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

The input must not contain more than 250 values.


•mutation

Adds gift card codes to a Cart without replacing any codes already applied. Gift card codes are case-insensitive.

To replace all gift card codes instead of adding to them, use cartGiftCardCodesUpdate.

Arguments

•ID!
required

The ID of the cart.

•[String!]!
required

The case-insensitive gift card codes to add.

The input must not contain more than 250 values.


•mutation

Removes gift cards from a Cart using their IDs. You can retrieve the IDs of applied gift cards from the cart's appliedGiftCards field.

Arguments

•ID!
required

The ID of the cart.

•[ID!]!
required

The gift cards to remove.

The input must not contain more than 250 values.


•mutation

Updates the gift card codes applied to the cart. Unlike cartGiftCardCodesAdd, which adds codes without replacing existing ones, this mutation sets the gift card codes for the cart. Gift card codes are case-insensitive.

Arguments

•ID!
required

The ID of the cart.

•[String!]!
required

The case-insensitive gift card codes.

The input must not contain more than 250 values.


•mutation

Adds one or more merchandise lines to an existing Cart. Each line specifies the product variant to purchase. Quantity defaults to 1 if not provided.

You can add up to 250 lines in a single request. Use CartLineInput to configure each line's merchandise, quantity, selling plan, custom attributes, and any parent relationships for nested line items such as warranties or add-ons.

Arguments

•ID!
required

The ID of the cart.

•[CartLineInput!]!
required

A list of merchandise lines to add to the cart.

The input must not contain more than 250 values.


•mutation

Removes one or more merchandise lines from a Cart. Accepts up to 250 line IDs per request. Returns the updated cart along with any errors or warnings.

Arguments

•ID!
required

The ID of the cart.

•[ID!]!
required

The merchandise line IDs to remove.

The input must not contain more than 250 values.


•mutation

Updates one or more merchandise lines on a Cart. You can modify the quantity, swap the merchandise, change custom attributes, or update the selling plan for each line. You can update a maximum of 250 lines per request.

Omitting the attributes field or setting it to null preserves existing line attributes. Pass an empty array to clear all attributes from a line.

Arguments

•ID!
required

The ID of the cart.

•[CartLineUpdateInput!]!
required

The merchandise lines to update.

The input must not contain more than 250 values.


•mutation

Updates the note on a Cart. The note is a text field that stores additional information, such as a personalized message from the buyer or special instructions for the order.

Arguments

•ID!
required

The ID of the cart.

•String!
required

The note on the cart.


•mutation

Updates the selected delivery option for one or more CartDeliveryGroup objects in a cart. Each delivery group represents items shipping to a specific address and offers multiple delivery options with different costs and methods.

Use this mutation when a customer chooses their preferred shipping method during checkout. The deliveryOptionHandle identifies which CartDeliveryOption to select for each delivery group.

Arguments

•ID!
required

The ID of the cart.

Anchor to selectedDeliveryOptionsselectedDeliveryOptions
•[CartSelectedDeliveryOptionInput!]!
required

The selected delivery options.

The input must not contain more than 250 values.



Was this section helpful?

•interface

Was this section helpful?