Hi everyone,
I’m working on calculating total sales using the Orders API and need some help with retrieving return dates. Specifically, when querying the GQL Orders API, the return object doesn’t include the createdAt
or updatedAt
fields, even though the documentation states that the createdAt
field is available and represents “the date and time when the return was created.”
Here’s the relevant snippet from the documentation:
When I query the API, I get this error:
Here’s the query I’m using:
query getOrderReturns($first: Int!, $query: String, $after: String) {
orders(first: $first, query: $query, after: $after) {
edges {
node {
id
returnStatus
cancelledAt
totalPriceSet { shopMoney { amount } }
currentTotalPriceSet { shopMoney { amount } }
originalTotalPriceSet { shopMoney { amount } }
subtotalPriceSet { shopMoney { amount } }
currentSubtotalPriceSet { shopMoney { amount } }
totalRefundedSet { shopMoney { amount } }
cancelledAt
refunds(first: 10) {
createdAt
updatedAt
id
note
return { id }
totalRefundedSet { shopMoney { amount currencyCode } }
refundLineItems(first:10) { nodes { lineItem { id } } }
}
returns(first: 10) {
edges {
node {
id
createdAt
name
status
decline { note reason }
totalQuantity
returnLineItems(first:10) {
nodes {
id
customerNote
quantity
refundableQuantity
refundedQuantity
returnReason
returnReasonNote
fulfillmentLineItem {
id
discountedTotalSet { shopMoney { amount } }
originalTotalSet { shopMoney { amount } }
lineItem { id }
}
}
}
}
}
}
}
}
pageInfo { hasNextPage endCursor }
}
}
To calculate total sales accurately, I need a way to identify the date a return was initiated. However, I don’t see a return date field in the REST API either.
Does anyone know of another field or workaround I can use to determine the return initiation date? Any help would be greatly appreciated!
Thanks in advance!