Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi,
In the shopify admin when can go to "Analytics" > "Dashboards" to find the metric "Total sales" as per the following screenshot:
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
Hi @SBD_
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.
Hey @souf,
Perhaps you could use the REST API? Tender transactions have an order_id property.
Scott | Developer Advocate @ Shopify