Change Discount Function Title after creation

Solved

Change Discount Function Title after creation

fwallace
Shopify Partner
40 0 4

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.

Accepted Solution (1)
SomeUsernameHe
Shopify Partner
515 57 109

This is an accepted solution.

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
}
}
}
}

 

 

 

Have I helped? Consider putting coffee in my mouth!
Buy Me a Coffee

View solution in original post

Replies 5 (5)

SomeUsernameHe
Shopify Partner
515 57 109

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
    }
  }
}

 

Have I helped? Consider putting coffee in my mouth!
Buy Me a Coffee
fwallace
Shopify Partner
40 0 4

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!

SomeUsernameHe
Shopify Partner
515 57 109

This is an accepted solution.

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
}
}
}
}

 

 

 

Have I helped? Consider putting coffee in my mouth!
Buy Me a Coffee
fwallace
Shopify Partner
40 0 4

Thanks so much!

SomeUsernameHe
Shopify Partner
515 57 109

You are welcome! Glad I could help! 

Any other questions feel free to ask!

Have I helped? Consider putting coffee in my mouth!
Buy Me a Coffee