I tried getting the discount_applications of the order object on frontend and it works without problem. but retrieving the order.discountApplications thru the graphql order API returns an empty object.
The order may not have any discount applications applied to it. In this case, the discountApplications field will be an empty array.
The discountApplications field may not be included in the GraphQL query that you are using. In this case, you will need to include the field in your query to retrieve its value.
There may be an issue with the GraphQL Order API endpoint or with your application’s authentication. In this case, you may need to check the error logs or contact Shopify support for further assistance.
To retrieve the discountApplications field of the order object using the GraphQL Order API, you will need to include the field in your query and ensure that your application is properly authenticated.
You can find more information about the GraphQL Order API in the Shopify documentation.
The DiscountApplication is an interface, so you will need to fragment on the types. To query non-code discounts, you can use something like the below:
query ($id: ID!) {
order (id:$id){
discountApplications (first:10){
nodes {
... Discounts
}
}
}
}
fragment Discounts on DiscountApplication {
... on AutomaticDiscountApplication {
title
value {
... on MoneyV2 {
amount
}
}
}
... on ScriptDiscountApplication {
title
value {
... on MoneyV2 {
amount
}
}
}
... on ManualDiscountApplication {
title
value {
... on MoneyV2 {
amount
}
}
}
}