Anchor to discountCodeAppUpdatediscount
discountCodeAppUpdate
mutation
Requires access scope.
Updates a code discount, where the discount type is provided by an app extension that uses Shopify Functions. Use this mutation when you need advanced, custom, or dynamic discount capabilities that aren't supported by Shopify's native discount types.
Anchor to Arguments
Arguments
- Anchor to codeAppDiscountcode•
App Discount DiscountCode requiredApp Input! The input fields required to update the discount.
- •ID!required
The ID of the discount to update.
Was this section helpful?
Anchor to DiscountCodeAppUpdatePayload returnsDiscountCodeAppUpdatePayload returns
- Anchor to codeAppDiscountcode•
App Discount The updated discount that the app provides.
- Anchor to userErrorsuser•
Errors [DiscountUser non-nullError!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Update an app code discount
- discountCodeAppUpdate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation discountCodeAppUpdate($codeAppDiscount: DiscountCodeAppInput!, $id: ID!) {
discountCodeAppUpdate(codeAppDiscount: $codeAppDiscount, id: $id) {
codeAppDiscount {
discountId
title
endsAt
}
userErrors {
field
message
}
}
}`,
{
variables: {
"id": "gid://shopify/DiscountCodeNode/549381256",
"codeAppDiscount": {
"title": "Take 5$ from order discount",
"endsAt": "2020-08-07T00:00:00Z"
}
},
},
);
mutation discountCodeAppUpdate($codeAppDiscount: DiscountCodeAppInput!, $id: ID!) {
discountCodeAppUpdate(codeAppDiscount: $codeAppDiscount, id: $id) {
codeAppDiscount {
discountId
title
endsAt
}
userErrors {
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation discountCodeAppUpdate($codeAppDiscount: DiscountCodeAppInput!, $id: ID!) { discountCodeAppUpdate(codeAppDiscount: $codeAppDiscount, id: $id) { codeAppDiscount { discountId title endsAt } userErrors { field message } } }",
"variables": {
"id": "gid://shopify/DiscountCodeNode/549381256",
"codeAppDiscount": {
"title": "Take 5$ from order discount",
"endsAt": "2020-08-07T00:00:00Z"
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation discountCodeAppUpdate($codeAppDiscount: DiscountCodeAppInput!, $id: ID!) {
discountCodeAppUpdate(codeAppDiscount: $codeAppDiscount, id: $id) {
codeAppDiscount {
discountId
title
endsAt
}
userErrors {
field
message
}
}
}`,
{
variables: {
"id": "gid://shopify/DiscountCodeNode/549381256",
"codeAppDiscount": {
"title": "Take 5$ from order discount",
"endsAt": "2020-08-07T00:00:00Z"
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation discountCodeAppUpdate($codeAppDiscount: DiscountCodeAppInput!, $id: ID!) {
discountCodeAppUpdate(codeAppDiscount: $codeAppDiscount, id: $id) {
codeAppDiscount {
discountId
title
endsAt
}
userErrors {
field
message
}
}
}`,
"variables": {
"id": "gid://shopify/DiscountCodeNode/549381256",
"codeAppDiscount": {
"title": "Take 5$ from order discount",
"endsAt": "2020-08-07T00:00:00Z"
}
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation discountCodeAppUpdate($codeAppDiscount: DiscountCodeAppInput!, $id: ID!) {
discountCodeAppUpdate(codeAppDiscount: $codeAppDiscount, id: $id) {
codeAppDiscount {
discountId
title
endsAt
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"id": "gid://shopify/DiscountCodeNode/549381256",
"codeAppDiscount": {
"title": "Take 5$ from order discount",
"endsAt": "2020-08-07T00:00:00Z"
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"id": "gid://shopify/DiscountCodeNode/549381256",
"codeAppDiscount": {
"title": "Take 5$ from order discount",
"endsAt": "2020-08-07T00:00:00Z"
}
}
Response
JSON{
"discountCodeAppUpdate": {
"codeAppDiscount": {
"discountId": "gid://shopify/DiscountCodeNode/549381256",
"title": "Take 5$ from order discount",
"endsAt": "2020-08-07T00:00:00Z"
},
"userErrors": []
}
}