Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to calculate Average Order Value using the Admin API

How to calculate Average Order Value using the Admin API

doabledanny
Shopify Partner
13 0 6

Using the GraphQL admin API, I need to calculate the Average Order Value using the same calculation defined in Shopify's reports documentation:

 

Equates to gross sales (excluding adjustments) - discounts (excluding adjustments) / number of orders. Adjustments include all edits, exchanges, or returns that are made to an order after it's initially created.

I've tried querying order.subtotalPriceSet, but that changes whenever the order is edited (e.g. if I add another line item to the order). How to I get the original subtotal price and original total discounts applied so that I can calculate the Average Order Value the same way that Shopify does?

Replies 0 (0)