Essentially, I am trying to make an API call to retrieve bulk list of returns for the month with the original order date, the order number, transaction type, and transaction amount. I know that what I have inserted below can obtain the info I want about a single order. But not sure what I need to do to get it in bulk based off of specified dates.
query getOrderTransactions {
order(id: "") {
name
subtotalPriceSet {
shopMoney {
amount
}
}
totalTaxSet {
shopMoney {
amount
}
}
totalShippingPriceSet {
shopMoney {
amount
}
}
transactions {
accountNumber
amountSet {
shopMoney {
amount
}
}
authorizationCode
authorizationExpiresAt
createdAt
errorCode
formattedGateway
gateway
id
kind
processedAt
status
test
}
}
}
It looks like you’re trying to retrieve a bulk list of returns for a specific time period using an API call. To do this, you’ll need to modify your query to include a filter for the date range you’re interested in.
Here’s an example query that retrieves a list of all orders created between March 1, 2022 and March 31, 2022, and includes information about the transactions and the original order date:
query {
orders(query: "created_at:>2022-03-01 AND created_at:<2022-03-31") {
edges {
node {
name
createdAt
transactions(first: 10) {
edges {
node {
kind
processedAt
amountSet {
shopMoney {
amount
}
}
}
}
}
}
}
}
}
You can modify the query to include additional information about the orders and transactions as needed, and adjust the date range to fit your needs.
1 Like
@EcomGraduates is on point here! The only thing I’d add to this is if you end up with a large list of transactions, you can add pagination like this:
query ($cursor: String) {
orders(first: 10, after: $cursor, query: “created_at:>2022-03-01 AND created_at:<2023-03-31”) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
name
createdAt
transactions(first: 10) {
kind
processedAt
amountSet {
shopMoney {
amount
}
}
}
}
}
}
}
This would make it easier to iterate through the full list without going over your rate limit or having to process the query as a bulk operation. Hope this helps!
Al | Shopify Developer Support
1 Like