Skip to content

cartDiscountCodeAdd

Mutationin Cart

Apply a discount code to the cart

Arguments

ArgumentTypeDescription
idID!
versionString
codeString!

Returns

CartDiscountCodeAddResponse!

FieldTypeDescription
cartCartCart information after discount code is added
cartErrors[CartDiscountCodeAddError!]Error details if discount code addition failed

Example

mutation {
cartDiscountCodeAdd(
id: "cart-123",
code: "SAVE10"
) {
cart {
id
discountCodes {
id
code
amount {
centAmount
currency
}
}
total {
gross {
centAmount
currency
}
}
}
cartErrors {
... on CartError {
code
message
}
}
}
}

The query is the example the schema documents. The response shows its shape with placeholder values.

Served by

@evolve-framework/commercetoolsResolved
@evolve-framework/medusaResolved
@evolve-framework/sfccResolved

Used by

The storefront packages that send it, in these GraphQL documents: