Menu
updateDiscountCode
Update an existing discount code — pass its current version and an array of update actions.
Use it in a workflow
- Add a step and choose the Commercetools connector.
- Pick the updateDiscountCode action (under Update).
- Fill in the fields below, then reference the result from later steps as
{{updatediscountcode.response.data}}.
Query
This is the mutation the action sends by default. Edit it in the step's Query field to change which fields come back.
mutation UpdateDiscountCode($version: Long!, $actions: [DiscountCodeUpdateAction!]!, $id: String, $key: String) {
updateDiscountCode(version: $version, actions: $actions, id: $id, key: $key) {
code
key
isActive
maxApplications
maxApplicationsPerCustomer
cartPredicate
applicationVersion
groups
cartDiscounts {
cartPredicate
stackingMode
isActive
requiresDiscountCode
key
discountGroupRef {
typeId
id
}
nameAllLocales {
locale
value
}
descriptionAllLocales {
locale
value
}
referenceRefs {
typeId
id
}
custom {
typeRef
type
}
validFrom
validUntil
storesRef {
typeId
key
}
stores {
id
version
key
nameAllLocales
languages
countries
productSelections
distributionChannelsRef
distributionChannels
supplyChannelsRef
supplyChannels
storefront
createdAt
lastModifiedAt
custom
createdBy
lastModifiedBy
}
discountGroup {
id
version
key
sortOrder
isActive
nameAllLocales
descriptionAllLocales
createdAt
lastModifiedAt
createdBy
lastModifiedBy
}
value {
type
}
target {
type
}
sortOrder
recurringOrderScope {
type
}
id
version
createdAt
lastModifiedAt
createdBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef
userRef
associateRef
attributedTo
}
lastModifiedBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef
userRef
associateRef
attributedTo
}
}
validFrom
validUntil
referenceRefs {
typeId
id
}
nameAllLocales {
locale
value
}
descriptionAllLocales {
locale
value
}
custom {
typeRef {
typeId
id
}
type {
key
nameAllLocales
descriptionAllLocales
resourceTypeIds
id
version
createdAt
lastModifiedAt
createdBy
lastModifiedBy
}
}
applicationCount
storesRef {
typeId
key
}
stores {
id
version
key
nameAllLocales {
locale
value
}
languages
countries {
code
}
productSelections {
productSelectionRef
productSelection
active
}
distributionChannelsRef {
typeId
id
}
distributionChannels {
id
version
key
roles
nameAllLocales
descriptionAllLocales
address
geoLocation
createdAt
lastModifiedAt
reviewRatingStatistics
custom
createdBy
lastModifiedBy
}
supplyChannelsRef {
typeId
id
}
supplyChannels {
id
version
key
roles
nameAllLocales
descriptionAllLocales
address
geoLocation
createdAt
lastModifiedAt
reviewRatingStatistics
custom
createdBy
lastModifiedBy
}
storefront {
checkoutUrlTemplate
orderUrlTemplate
termsOfServiceUrl
privacyPolicyUrl
refundPolicyUrl
shippingPolicyUrl
cookiePolicyUrl
imprintUrl
faqUrl
contactUrl
}
createdAt
lastModifiedAt
custom {
typeRef
type
}
createdBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef
userRef
associateRef
attributedTo
}
lastModifiedBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef
userRef
associateRef
attributedTo
}
}
cartDiscountRefs {
typeId
id
}
id
version
createdAt
lastModifiedAt
createdBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef {
typeId
id
}
userRef {
typeId
id
}
associateRef {
typeId
id
}
attributedTo {
clientId
source
userRef
}
}
lastModifiedBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef {
typeId
id
}
userRef {
typeId
id
}
associateRef {
typeId
id
}
attributedTo {
clientId
source
userRef
}
}
}
}
Variables
Pass these as a JSON object in the step's Variables field.
{
"version": "string",
"actions": [
{
"changeCartDiscounts": {
"cartDiscounts": "string"
},
"changeGroups": {
"groups": "string"
},
"changeIsActive": {
"isActive": "string"
},
"setCartPredicate": {
"cartPredicate": "string"
},
"setCustomField": {
"name": "string",
"value": "string"
},
"setCustomType": {
"fields": "string",
"type": "string",
"typeKey": "string",
"typeId": "string"
},
"setDescription": {
"description": "string"
},
"setKey": {
"key": "string"
},
"setMaxApplications": {
"maxApplications": "string"
},
"setMaxApplicationsPerCustomer": {
"maxApplicationsPerCustomer": "string"
},
"setName": {
"name": "string"
},
"setValidFrom": {
"validFrom": "string"
}
}
],
"id": "string",
"key": "string"
}
Response
Read the result with {{updatediscountcode.response.data.data.updateDiscountCode}}. If the API returns errors, the step fails and they are at {{updatediscountcode.response.data.errors}}.
Need more? See the Commercetools guide for connection setup and behaviour shared by every action.
Was this page helpful?