Change Discount Function Title after creation

Hi all –

I have created and deployed a discount function following the tutorials on my development store. I followed the instructions to create the discount on my development store with the following GraphQL mutation via the GraphQL explorer.

mutation {
  discountAutomaticAppCreate(automaticAppDiscount: {
    title: "Volume discount",
    functionId: "YOUR_FUNCTION_ID_HERE",
    startsAt: "2022-06-22T00:00:00"
  }) {
     automaticAppDiscount {
      discountId
     }
     userErrors {
      field
      message
     }
  }
}

I want to change the β€œVolume Discount” title to something else, we may have in production basic discounts that we would like to change on a promotional basis – the code would remain but the discount title would change linked to promotions.

Is there a way to do this? I do not see anything in either the Graphql explorer or the docs.

Thanks.

Try using discountAutomaticAppUpdate: https://shopify.dev/docs/api/admin-graphql/2024-01/mutations/discountAutomaticAppUpdate

mutation {
  discountAutomaticAppUpdate(
    id: "gid://shopify/DiscountNode/YOUR_DISCOUNT_ID_HERE",
    automaticAppDiscount: {
      title: "New Discount Title"
    }
  ) {
    discountNode {
      id
    }
    userErrors {
      field
      message
    }
  }
}
2 Likes

Awesome, but how can I find the id: β€œgid://shopify/DiscountNode/YOUR_DISCOUNT_ID_HERE”, is there a way to find the gid ?

Thanks again!

You should receive it on the response when you create it or you will have to query it.

{
discounts(first: 5) {
edges {
node {
id
title
}
}
}
}

Thanks so much!

1 Like

You are welcome! Glad I could help!

Any other questions feel free to ask!