Migrate your app
The Storefront Cart API is part of the Storefront API, which is a GraphQL API. It's used for building buyer experiences, such as custom storefronts, mobile apps, apps that interact with Cart and Storefront and more. You can access the Storefront Cart API at the following endpoint:
Create a Cart
Anchor link to section titled "Create a Cart"The Storefront Cart API enables you to assemble a buyer's purchase, providing all relevant details back to the buyer before transitioning into the checkout process. This means you can add, remove, or update items in the cart, apply discounts, and more, before you create the checkout. Modifying a cart instead of a checkout provides your application a more feature-rich and performant way of assembly.
Deprecated: Checkout API's checkoutCreate
Anchor link to section titled "Deprecated: Checkout API's checkoutCreate"
New: Storefront Cart API's cartCreate
Anchor link to section titled "New: Storefront Cart API's cartCreate"
Deprecated: Checkout API error handling
Anchor link to section titled "Deprecated: Checkout API error handling"In the Checkout API, to handle errors you requested checkoutUserErrors
:
New: Storefront Cart API error handling
Anchor link to section titled "New: Storefront Cart API error handling"With the Storefront Cart API, you request userErrors
to receive information about errors that are related to the entire API surface:
Update a cart
Anchor link to section titled "Update a cart"Updating the cart enables you to adjust the line items, discounts, attributes, notes, and more, before finalizing the cart and sending the buyer to checkout. The Storefront Cart API provides the following main methods for updating line items in the cart:
The cartLinesUpdate
mutation behaves similarly to checkoutLineItemsReplace
in the Checkout API. It replaces the existing line items in the cart with the new line items provided in the lines argument. This is useful when you want to completely refresh the cart contents.
Deprecated: Checkout API's checkoutLineItemsReplace
Anchor link to section titled "Deprecated: Checkout API's checkoutLineItemsReplace"
New: Storefront Cart API's cartLinesUpdate
Anchor link to section titled "New: Storefront Cart API's cartLinesUpdate"
If you want to add new line items to the existing ones in the cart, you should use cartLinesAdd
. This enables you to build up the cart contents incrementally, without discarding the current lines.
Deprecated: Checkout API's checkoutDiscountCodeApplyV2
Anchor link to section titled "Deprecated: Checkout API's checkoutDiscountCodeApplyV2"With the Checkout API, discount codes aren't stackable:
New: Storefront Cart API's cartDiscountCodesUpdate
Anchor link to section titled "New: Storefront Cart API's cartDiscountCodesUpdate"The Storefront Cart API supports stackable discount codes. The discountCodes
field in the cartDiscountCodesUpdate
mutation is an array, which enables you to apply multiple discount codes to the cart:
Associate a customer
Anchor link to section titled "Associate a customer"The Storefont Cart API provides a straightforward way to attach both anonymous and authenticated buyer information to the cart using the cartBuyerIdentityUpdate
mutation. The following examples compare updating a shipping address using the Checkout API and the Storefront Cart API.
Deprecated: Checkout API's checkoutShippingAddressUpdateV2
Anchor link to section titled "Deprecated: Checkout API's checkoutShippingAddressUpdateV2"
New: Storefront Cart API's cartBuyerIdentityUpdate
Anchor link to section titled "New: Storefront Cart API's cartBuyerIdentityUpdate"The Storefront Cart API enables you to update the buyer's identity, including their delivery address, using the cartBuyerIdentityUpdate
mutation.
You can retrieve the access token using either the customerAccessTokenCreate
or customerAccessTokenCreateWithMultipass
mutations.
Deprecated: Checkout API's checkoutCustomerAssociateV2
Anchor link to section titled "Deprecated: Checkout API's checkoutCustomerAssociateV2"
New: Storefront Cart API's cartBuyerIdentityUpdate
Anchor link to section titled "New: Storefront Cart API's cartBuyerIdentityUpdate"
Complete the checkout
Anchor link to section titled "Complete the checkout"In the Checkout API, you complete the checkout by retrieving the checkout web URL from the Checkout
object's webUrl
field. In the Storefront Cart API, you can retrieve the checkoutUrl
from the Cart
object at any point in the flow to send the buyer to the Shopify web checkout.
Deprecated: Checkout API's webURL
Anchor link to section titled "Deprecated: Checkout API's webURL"
New: Storefront Cart API's checkoutURL
Anchor link to section titled "New: Storefront Cart API's checkoutURL"