How to identify in graph ql API whether the discount is applied to the order level or item level

Hi

I am testing integration between Shopify and our system and had a question about how discounts are shown in graph ql.
My test scenario is:
I have an order with 2 items. There is item discount of 10% on one item. There is also an order discount of 10$ on this order. I need to import this order into my system.

The query I am using to get discount data is:

query GetOrderDiscountAllocations {

order(id: “gid://shopify/Order/6435656401094”) {

id

name

discountApplications(first: 10) {

  edges {

    node {

      allocationMethod

      targetSelection

      targetType

      value {

        ... **on** MoneyV2 {

          amount

          currencyCode

        }

        ... **on** PricingPercentageValue {

          percentage

        }

      }

    }

  }

}

lineItems(first: 10) {

  edges {

    node {

      id

      title

      discountAllocations {

        allocatedAmount {

          amount

          currencyCode

        }

        discountApplication {

          allocationMethod

          targetSelection

          targetType

          value {

            ... **on** MoneyV2 {

              amount

              currencyCode

            }

            ... **on** PricingPercentageValue {

              percentage

            }

          }

        }

      }

    }

  }

}

}

}

In the data retrieved, I am see the following:
{

"data": {

    "order": {

        "id": "gid://shopify/Order/6435656401094",

        "name": "#3007",

        "discountApplications": {

            "edges": \[

                {

                    "node": {

                        "allocationMethod": "ACROSS",

                        "targetSelection": "ALL",

                        "targetType": "LINE_ITEM",

                        "value": {

                            "amount": "10.0",

                            "currencyCode": "USD"

                        }

                    }

                },

                {

                    "node": {

                        "allocationMethod": "EACH",

                        "targetSelection": "ENTITLED",

                        "targetType": "LINE_ITEM",

                        "value": {

                            "percentage": 10.0

                        }

                    }

                }

            \]

        },

        "lineItems": {

            "edges": \[

                {

                    "node": {

                        "id": "gid://shopify/LineItem/15095136911558",

                        "title": "Lego 500 piece set",

                        "discountAllocations": \[

                            {

                                "allocatedAmount": {

                                    "amount": "1.82",

                                    "currencyCode": "USD"

                                },

                                "discountApplication": {

                                    "allocationMethod": "ACROSS",

                                    "targetSelection": "ALL",

                                    "targetType": "LINE_ITEM",

                                    "value": {

                                        "amount": "10.0",

                                        "currencyCode": "USD"

                                    }

                                }

                            }

                        \]

                    }

                },

                {

                    "node": {

                        "id": "gid://shopify/LineItem/15095136944326",

                        "title": "Acer Laptop Computer",

                        "discountAllocations": \[

                            {

                                "allocatedAmount": {

                                    "amount": "8.18",

                                    "currencyCode": "USD"

                                },

                                "discountApplication": {

                                    "allocationMethod": "ACROSS",

                                    "targetSelection": "ALL",

                                    "targetType": "LINE_ITEM",

                                    "value": {

                                        "amount": "10.0",

                                        "currencyCode": "USD"

                                    }

                                }

                            },

                            {

                                "allocatedAmount": {

                                    "amount": "50.0",

                                    "currencyCode": "USD"

                                },

                                "discountApplication": {

                                    "allocationMethod": "EACH",

                                    "targetSelection": "ENTITLED",

                                    "targetType": "LINE_ITEM",

                                    "value": {

                                        "percentage": 10.0

                                    }

                                }

                            }

                        \]

                    }

                }

            \]

        }

    }

},

"extensions": {

    "cost": {

        "requestedQueryCost": 21,

        "actualQueryCost": 9,

        "throttleStatus": {

            "maximumAvailable": 2000.0,

            "currentlyAvailable": 1991,

            "restoreRate": 100.0

        }

    }

}

}

What is the identifier that can tell me whether a discount is applied on line level or whether a discount is applied to the order?

@Tushar_Pandita if I understand correctly what you are after is the information provided by the discount application data with the allocationMethod, targetSelection and targetType. You need to use a combination of this information to understand how it applies. Looking at the data return if looks like the $10 applied to each item and the 10% to the second one only.

@Mathieu_Nunez

I see that too, but I just wanted to confirm that if the allocation method = Across, Target Selection = All, then it means that this discount was applied on the order level.
The reason for my confusion is that target_type = LINE_ITEM, so I dont 1005 know if teh discount was for the order or for the line.

Yes that’s a good point. Given all these values you would assume it applies to the order.