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 field to direct buyers to Shopify's web checkout to complete their purchase.
Learn more about interacting with carts.
Anchor to FieldsFields
- appliedGiftCards ([AppliedGiftCard!]!)
- attribute (Attribute)
- attributes ([Attribute!]!)
- buyerIdentity (CartBuyerIdentity!)
- checkoutUrl (URL!)
- cost (CartCost!)
- createdAt (DateTime!)
- delivery (CartDelivery!)
- deliveryGroups (CartDeliveryGroupConnection!)
- discountAllocations ([CartDiscountAllocation!]!)
- discountCodes ([CartDiscountCode!]!)
- id (ID!)
- lines (BaseCartLineConnection!)
- metafield (Metafield)
- metafields ([Metafield]!)
- note (String)
- totalQuantity (Int!)
- updatedAt (DateTime!)
- estimatedCost (CartEstimatedCost!): deprecated
- Anchor to appliedGiftCardsapplied•[Applied
Gift Cards Gift Card!]! non-null The gift cards that have been applied to the cart.
- Anchor to attributeattribute•Attribute
An attribute associated with the cart.
- •String!required
The key of the attribute.
Arguments
- •String!
- Anchor to attributesattributes•[Attribute!]!non-null
The attributes associated with the cart. Attributes are represented as key-value pairs.
- Anchor to buyerIdentitybuyer•Cart
Identity Buyer Identity! non-null Information about the buyer that's interacting with the cart.
- Anchor to checkoutUrlcheckout•URL!
Url non-null The URL of the checkout for the cart.
- Anchor to costcost•Cart
Cost! 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
costfield uses thefield to determine international pricing.- Anchor to createdAtcreated•Date
At Time! non-null The date and time when the cart was created.
- Anchor to deliverydelivery•Cart
Delivery! non-null The delivery properties of the cart.
- Anchor to deliveryGroupsdelivery•Cart
Groups Delivery Group Connection! 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.
- Anchor to firstfirst•Int
Returns up to the first
nelements from the list.- Anchor to afterafter•String
Returns the elements that come after the specified cursor.
- Anchor to lastlast•Int
Returns up to the last
nelements from the list.- Anchor to beforebefore•String
Returns the elements that come before the specified cursor.
- Anchor to reversereverse•BooleanDefault:false
Reverse the order of the underlying list.
- Anchor to withCarrierRateswith•Boolean
Carrier Rates 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
@deferdirective.For more information, refer to fetching carrier-calculated rates for the cart using
@defer.
Arguments
- Anchor to discountAllocationsdiscount•[Cart
Allocations Discount Allocation!]! non-null The discounts that have been applied to the entire cart.
- Anchor to discountCodesdiscount•[Cart
Codes Discount Code!]! non-null The case-insensitive discount codes that the customer added at checkout.
- •ID!non-null
A globally-unique ID.
- Anchor to lineslines•Base
Cart Line Connection! non-null A list of lines containing information about the items the customer intends to purchase.
- Anchor to firstfirst•Int
Returns up to the first
nelements from the list.- Anchor to afterafter•String
Returns the elements that come after the specified cursor.
- Anchor to lastlast•Int
Returns up to the last
nelements from the list.- Anchor to beforebefore•String
Returns the elements that come before the specified cursor.
- Anchor to reversereverse•BooleanDefault:false
Reverse the order of the underlying list.
Arguments
- Anchor to metafieldmetafield•MetafieldToken access required
A custom field, including its
namespaceandkey, that's associated with a Shopify resource for the purposes of adding and storing additional information.- Anchor to namespacenamespace•String
The container the metafield belongs to. If omitted, the app-reserved namespace will be used.
- •String!required
The identifier for the metafield.
Arguments
- Anchor to metafieldsmetafields•[Metafield]!non-null Token access required
A list of custom fields that a merchant associates with a Shopify resource.
- Anchor to identifiersidentifiers•[Has
Metafields Identifier!]! required The list of metafields to retrieve by namespace and key.
The input must not contain more than
250values.
Arguments
- Anchor to notenote•String
A note that's associated with the cart. For example, the note can be a personalized message to the buyer.
- Anchor to totalQuantitytotal•Int!
Quantity non-null The total number of items in the cart.
- Anchor to updatedAtupdated•Date
At Time! non-null The date and time when the cart was updated.
- Anchor to estimatedCostestimated•Cart
Cost Estimated Cost! non-nullDeprecated
Anchor to QueriesQueries
- cart (Cart)
- •query
Returns a
Cartby 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
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.- •ID!required
The ID of the cart.
Arguments
- •ID!
Anchor to MutationsMutations
- cartAttributesUpdate (CartAttributesUpdatePayload)
- cartBuyerIdentityUpdate (CartBuyerIdentityUpdatePayload)
- cartCreate (CartCreatePayload)
- cartDeliveryAddressesAdd (CartDeliveryAddressesAddPayload)
- cartDeliveryAddressesRemove (CartDeliveryAddressesRemovePayload)
- cartDeliveryAddressesReplace (CartDeliveryAddressesReplacePayload)
- cartDeliveryAddressesUpdate (CartDeliveryAddressesUpdatePayload)
- cartDiscountCodesUpdate (CartDiscountCodesUpdatePayload)
- cartGiftCardCodesAdd (CartGiftCardCodesAddPayload)
- cartGiftCardCodesRemove (CartGiftCardCodesRemovePayload)
- cartGiftCardCodesUpdate (CartGiftCardCodesUpdatePayload)
- cartLinesAdd (CartLinesAddPayload)
- cartLinesRemove (CartLinesRemovePayload)
- cartLinesUpdate (CartLinesUpdatePayload)
- cartNoteUpdate (CartNoteUpdatePayload)
- cartSelectedDeliveryOptionsUpdate (CartSelectedDeliveryOptionsUpdatePayload)
- •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.- Anchor to attributesattributes•[Attribute
Input!]! required An array of key-value pairs that contains additional information about the cart.
The input must not contain more than
250values.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
Arguments
- •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.
- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to buyerIdentitybuyer•Cart
Identity Buyer Identity Input! required The customer associated with the cart. Used to determine international pricing. Buyer identity should match the customer's shipping address.
Arguments
- •mutation
Creates a new
Cartfor 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
that directs the buyer to complete their purchase.- Anchor to inputinput•Cart
Input The fields used to create a cart.
Arguments
- •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.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to addressesaddresses•[Cart
Selectable Address Input!]! required A list of delivery addresses to add to the cart.
The input must not contain more than
250values.
Arguments
- •mutation
Removes delivery addresses from a
Cartby their IDs, allowing batch removal in a single request.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to addressIdsaddress•[ID!]!
Ids required A list of delivery addresses by handle to remove from the cart.
The input must not contain more than
250values.
Arguments
- •mutation
Replaces all delivery addresses on a
Cartwith a new set of addresses in a single operation. Unlike, 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.
- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to addressesaddresses•[Cart
Selectable Address Input!]! required A list of delivery addresses to replace on the cart.
The input must not contain more than
250values.
Arguments
- •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.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to addressesaddresses•[Cart
Selectable Address Update Input!]! required The delivery addresses to update.
The input must not contain more than
250values.
Arguments
- •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
in the cart'sfield to see whether the code is applicable to the cart's current contents.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to discountCodesdiscount•[String!]!
Codes required The case-insensitive discount codes that the customer added at checkout.
The input must not contain more than
250values.
Arguments
- •mutation
Adds gift card codes to a
Cartwithout replacing any codes already applied. Gift card codes are case-insensitive.To replace all gift card codes instead of adding to them, use
.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to giftCardCodesgift•[String!]!
Card Codes required The case-insensitive gift card codes to add.
The input must not contain more than
250values.
Arguments
- •mutation
Removes gift cards from a
Cartusing their IDs. You can retrieve the IDs of applied gift cards from the cart'sfield.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to appliedGiftCardIdsapplied•[ID!]!
Gift Card Ids required The gift cards to remove.
The input must not contain more than
250values.
Arguments
- •mutation
Updates the gift card codes applied to the cart. Unlike
, which adds codes without replacing existing ones, this mutation sets the gift card codes for the cart. Gift card codes are case-insensitive.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to giftCardCodesgift•[String!]!
Card Codes required The case-insensitive gift card codes.
The input must not contain more than
250values.
Arguments
- •mutation
Adds one or more merchandise lines to an existing
Cart. Each line specifies the product variant to purchase. Quantity defaults to1if not provided.You can add up to 250 lines in a single request. Use
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.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to lineslines•[Cart
Line Input!]! required A list of merchandise lines to add to the cart.
The input must not contain more than
250values.
Arguments
- •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.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to lineIdsline•[ID!]!
Ids required The merchandise line IDs to remove.
The input must not contain more than
250values.
Arguments
- •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
attributesfield or setting it to null preserves existing line attributes. Pass an empty array to clear all attributes from a line.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to lineslines•[Cart
Line Update Input!]! required The merchandise lines to update.
The input must not contain more than
250values.
Arguments
- •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.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to notenote•String!required
The note on the cart.
Arguments
- •mutation
Updates the selected delivery option for one or more
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
identifies whichto select for each delivery group.- Anchor to cartIdcart•ID!
Id required The ID of the cart.
- Anchor to selectedDeliveryOptionsselected•[Cart
Delivery Options Selected Delivery Option Input!]! required The selected delivery options.
The input must not contain more than
250values.
Arguments