Customer.averageOrderAmountV2 value is different from the one shown on Shopify admin

ttpp
Shopify Partner
4 0 1

I'm now testing Customer query and found the averageOrderAmountV2 value in the response object different from the one shown on the customer page on Shopify admin.

Seems the value in the response is calculated without refunded orders, and the one on Shopify admin takes them into account, ending up with those different results. Is that correct? Or where can I find the API specs to see how it's calculated?

And either way, is there a way to get via API the same value as on Shopify admin?

Replies 3 (3)

ShopifyDevSup
Shopify Staff
1440 236 492

Hi @ttpp 👋

 

The `Customer.averageOrderAmountV2` field reflects the average order amount accounting for refunds. You can verify this with a query like the below. If the Admin UI is displaying a different figure, I'd recommend contacting support here using an authenticated account with access to the merchant store so that the team can investigate further. 

 

{
    customer(id: "gid://shopify/Customer/1234"){
        amountSpent {
            amount
        }
        averageOrderAmountV2 {
            amount
        }
        orders (first:200) {
            nodes {
                id
                refunds {
                    totalRefundedSet {
                        shopMoney {
                            amount
                        }
                    }
                }
                currentTotalPriceSet {
                    shopMoney {
                        amount
                    }
                }
            }
        }
    }
}

 

Hope that helps!

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

ttpp
Shopify Partner
4 0 1

Thank you for your reply.

 

I tested with a customer with 2 orders. The orders are as follows.

order1: 50JPY, REFUNDED
order2: 100JPY, NOT REFUNDED

 

And the result of customer query is as below:

"averageOrderAmountV2": {"amount": "50.0", "currencyCode": "JPY"},

averageOrderAmountV2 seems to be calculated as "100 / 2".
total of "NOT" refunded orders amount / total of "any" orders count.

Is there an error in the calculation method?

ShopifyDevSup
Shopify Staff
1440 236 492

Hey @ttpp,

Refunded orders should still be associated with the customer, they just no longer have a value to the shop. I would recommend using the Customer.numberOfOrders field as a reference as well.

Cheers!

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