How to Calculate Total Discounts from REST API order in 2023

Solved

How to Calculate Total Discounts from REST API order in 2023

Piam
Shopify Partner
25 1 11

Looking for best practices for this.

 

The API has changed a lot and it's not well documented what all the fields discount fields are for.

 

Does anyone have a suggestions?

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

ShopifyDevSup
Shopify Staff
1453 238 499

This is an accepted solution.

Hi @Piam!

There is a field on the Order resource called current_total_discounts. It's succinctly described in the docs as:

The current total discounts on the order in the shop currency. The value of this field reflects order edits, returns, and refunds.

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
1453 238 499

This is an accepted solution.

Hi @Piam!

There is a field on the Order resource called current_total_discounts. It's succinctly described in the docs as:

The current total discounts on the order in the shop currency. The value of this field reflects order edits, returns, and refunds.

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

Thanks for your help!

 

I had a hard time finding the solution, it turns out the first time you open the page, it only shows a few fields. To access all the fields, you need to click "Show 67 hidden fields" and then it becomes searchable.

Piam_0-1675388740567.png

That small UX decision caused me some headaches, but I'm glad we found the solution.

Thank you again!

 

 

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