Total sales and graphql API

New Member
4 0 0

Hi,

 

In the shopify admin when can go to "Analytics" > "Dashboards" to find the metric "Total sales" as per the following screenshot:

 

Screenshot from 2019-11-26 11-51-11.png

 

I'm working with the GraphQL API to recreate this number. I could achieve it by fetching the Order object (https://help.shopify.com/en/api/graphql-admin-api/reference/object/order) using the field `Order.subtotalPriceSet.shopMoney.amount` to which I deduct the sum of refunds made on the same day. To find those refunds I use the fields `Order.refunds.createAt` and I use the value `Order.refunds.totalRefundSet.shopMoney.amount`.

 

So basically the formula is this one: {total order sales for that day} - {total refunds amounts for that day}.

 

However I have an issue. Let's say that I fetched from API orders for this month, but a refund was made this month for an order made last month. Then I don't have access to this refund. We cannot query list of refunds for a date range from the API. 

 

The question is the following: Is there a way to query transactions made for a given time range and that allows us to calculate total sales as well as gross sales, discounts, refunds, net sales, etc...?

 

Thanks

 

 

0 Likes
Shopify Staff
Shopify Staff
268 36 38

Hey @souf,

 

Tender Transactions (REST / GraphQL) might be helpful here. They can be filter on processed_at.

 

0 Likes
New Member
4 0 0

Hi @scottydont 

 

Thanks for suggestion, I just gave a quick look, but apparently we cannot associate a tender transaction to an order from the GraphQL API, is that right?

 

In the interim I could manage to use Order's filter `updated_at` to find the refunds I need. I still have some discrepancies because of some refund having 0$ values in the API when it's not the case in the ui for reasons I ignore.

0 Likes
Shopify Staff
Shopify Staff
268 36 38

Hey @souf,

 

Perhaps you could use the REST API? Tender transactions have an order_id property.

 

03-24-6mo1f-od2e9(1).jpg

0 Likes