Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Accessing DiscountApplication's title and description via graphQL

Accessing DiscountApplication's title and description via graphQL

magnetiic
Shopify Partner
4 0 3

I am processing Shopify orders with our external systems. In order to properly handle discounts, I need to be able to access each discount application's title and description. Via the Admin REST API, I can access this with no problem. However, we are leveraging the graphQL API to access additional information in a single call. While I am able to access discountApplications and see that the type is ScriptDiscountApplication, I do not seem to be able to access it as a ScriptDiscountApplication and therefore cannot retrieve its title and description. Is anyone aware of any way to access a discounts title and description via the admin graphQL?

Ideally, I'd be able to leverage this: https://shopify.dev/api/admin/graphql/reference/orders/scriptdiscountapplication#fields-2021-07 but on the order connection I only seem to be able to access this: https://shopify.dev/api/admin/graphql/reference/orders/discountapplication

Rest Response:

magnetiic_0-1631112446773.png

Graph QL response:

magnetiic_1-1631112500798.png

 

 

Replies 5 (5)

awwdam
Shopify Staff
249 42 38

Hey @magnetiic,

Would you be able to share an example of a formatted GraphQL request to the Order object where the DiscountApplication connection and ScriptDiscountApplication fields aren't returning the info that is expected? Additionally, an x-request-id from the response header would also be helpful! With that I would be happy to take a close look or pass back any insights!- Cheers!

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

piterwhite86
Shopify Partner
1 0 0

Same requirement as yours, but not resolved yet in 2023-07 version...

carstent
Shopify Partner
2 0 2

I have the same problem - we create our own invoices and have lines displaying the used coupon code. We cannot move to GraphQL because this is not available.

ShopifyDevSup
Shopify Staff
1453 238 527

Hey @carstent , thanks for sharing that. 

 

Just looking here, to get the ScriptDiscountApplication on the order object, a query like this should work to return those details: 

 

{
   orders(first: 10) {
       nodes {
           id
           discountApplications(first: 10) {
               nodes {
                   ... on ScriptDiscountApplication {
                       title
                       description
                       value {
                           ... on MoneyV2 {
                               amount
                               currencyCode
                           }
                           ... on PricingPercentageValue {
                               percentage
                           }
                       }
                   }
               }
           }
       }
   }
}

Hope that helps, 

 

- Kyle G. 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog