createEmptyCart
createEmptyCart is a Magento 2 GraphQL mutation in the Quote module. Create an empty shopping cart for a guest or logged in user. It returns String and requires an Authorization header (Bearer customer token).
Deprecated: Use `Mutation.createGuestCart` or `Query.customerCart` for logged in customer
Last verified: against Magento 2.4.9.
Returns
String
Resolver class
\Magento\QuoteGraphQl\Model\Resolver\CreateEmptyCart
Arguments
An optional input object that assigns the specified ID to the cart.
Example request
Auto-generated from the SDL — paste-ready against your store's /graphql endpoint. Replace the host, store code, and any required values before running.
Headers
Query
mutation {
createEmptyCart
}Variables
{}Related in QuoteGraphQl
Other fields shipped by the same module.
addProductsToCart
Add any type of product to the cart.
Quote · returns AddProductsToCartOutput
addSimpleProductsToCart
Add one or more simple products to the specified cart. We recommend using `addProductsToCart` instead.
Quote · returns AddSimpleProductsToCartOutput
addVirtualProductsToCart
Add one or more virtual products to the specified cart. We recommend using `addProductsToCart` instead.
Quote · returns AddVirtualProductsToCartOutput
applyCouponToCart
Apply a pre-defined coupon code to the specified cart.
Quote · returns ApplyCouponToCartOutput
assignCustomerToGuestCart
phpcs:ignore Magento2.GraphQL.ValidArgumentName
Quote · returns Cart!
cart
phpcs:ignore Magento2.GraphQL.ValidArgumentName
Quote · returns Cart
Every Magento dev tool, in one hosted workspace.
Free to sign up. Nothing to install. Drafts, audits, and projects saved across every tool.