Solved

What field to use to calculate total discounts in Shopify API post June 2022?

Piam
Shopify Partner
25 1 11

We used to use shopify_order.total_discounts_set.shop_money.amount to figure out how much discounts a store had. However, somewhere around June 2022, the API changed and our results started to diverge from what some stores see in the Shopify Dashboard.

Does anyone know what we should be using instead?

Kind regards,

Piam

Cofounder, By the Numbers
(https://apps.shopify.com/by-the-numbers)
piam@bythenumbersapp.com
Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1322 218 457

This is an accepted solution.

Hi @Piam , Do you have examples of orders where your seeing divergent results or can you share more details of the call and response headers that you are using? We have some example query for grapqhQL here if it helps.  

{
orders(first: 10) {
nodes {
discountApplications(first: 5) {
nodes {
allocationMethod
value
targetType
targetSelection
__typename
}
}
cartDiscountAmountSet {
shopMoney {
amount
}
}
totalDiscountsSet {
shopMoney {
amount
}
}
}
}
}


 

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

View solution in original post

Replies 2 (2)

ShopifyDevSup
Shopify Staff
1322 218 457

This is an accepted solution.

Hi @Piam , Do you have examples of orders where your seeing divergent results or can you share more details of the call and response headers that you are using? We have some example query for grapqhQL here if it helps.  

{
orders(first: 10) {
nodes {
discountApplications(first: 5) {
nodes {
allocationMethod
value
targetType
targetSelection
__typename
}
}
cartDiscountAmountSet {
shopMoney {
amount
}
}
totalDiscountsSet {
shopMoney {
amount
}
}
}
}
}


 

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

Piam
Shopify Partner
25 1 11

Thank you for your response!

 

The issue was that I couldn't search the docs correctly:

Piam_0-1675389155241.png

If you don't click the "show 67 hidden fields" arrow nothing in it is searchable.

So I missed the documentation!

 

Cheers,

Piam

Cofounder, By the Numbers
(https://apps.shopify.com/by-the-numbers)
piam@bythenumbersapp.com