GraphiQL Orders Discounts

Amichay
Excursionist
23 0 1

We are using GraphiQL to fetch orders.

The discounts data is not fit to the UI reports.

 

one order for example,

API discounts - 29,980

UI discounts - 25,193.27

 

The other numbers, like taxes and total sales are fit -> it is not a currency difference.

 

The same results with totalDiscountsSet node and cartDiscountAmountSet node.

 

Please help me to explain the difference.

0 Likes
Amichay
Excursionist
23 0 1

Jumping

0 Likes
ayadibaha
Shopify Partner
9 0 0

I have the same problem with the REST Admin API. For some orders, I don't get the exact same discount amount. Did you find a solution?

0 Likes
Amichay
Excursionist
23 0 1

No. Waiting for Shopify staff...

0 Likes
Greg_Kujawa
Shopify Partner
965 80 205

@Amichay how are you handling the GraphQL API request? Since there are specific fields that need to be referenced to determine the order line item discount amounts. And then you'd need to write code to iterate through the results to tally up the grand total.

For example, below where I'd consider the order's sum lineItem.discountAllocations.allocatedAmountSet.presentmentMoney.amount value to be the discounted amount.

{
  order(id: "gid://shopify/Order/1863955054644") {
    lineItems(first: 5) {
      edges {
        node {
          discountAllocations {
            allocatedAmountSet {
              presentmentMoney {
                amount
                currencyCode
              }
            }
          }
        }
      }
    }
  }
}

 

0 Likes
Amichay
Excursionist
23 0 1

Hi @Greg_Kujawa 

After using lineItem.discountAllocations.allocatedAmountSet.presentmentMoney.amount

I still get results that are different from the UI results.

 

Any idea why?

0 Likes