CustomerOrdersQuery
Description
Retrieves a list of orders for a customer. This query allows you to fetch all orders associated with a specific customer email address.
Endpoint
query getCustomerOrders($email: String, $limit: Int, $offset: Int) {
getCustomerOrders(email: $email, limit: $limit, offset: $offset) {
totalCount
items {
id
number
status
total {
value
currency
}
orderedAt
}
}
}
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
| String | No | The email address of the customer whose orders to retrieve. If not provided, the query will attempt to use the email of the currently logged-in user. | |
| limit | Int | No | Maximum number of orders to return. Defaults to 20. |
| offset | Int | No | Result offset for pagination. Defaults to 0. |
Return Values
The query returns an OrderList object with the following fields:
| Field | Type | Description |
|---|---|---|
| totalCount | Int | Total number of matching orders. |
| items | [Order] | Paginated list of orders. |
Each item in items includes:
| Field | Type | Description |
|---|---|---|
| id | Int | The unique identifier for the order. |
| number | String | The order number or increment ID, typically used as a reference number for customers. |
| status | String | The current status of the order (e.g., "pending", "processing", "complete", "canceled"). |
| total | Money | The total amount of the order. |
| orderedAt | String | The date and time when the order was placed. |
Money Structure
The total field uses the Money structure:
| Field | Type | Description |
|---|---|---|
| value | Float! | The numerical value of the amount. |
| currency | String! | The currency code (e.g., "USD"). |
Usage Example
query {
getCustomerOrders(email: "customer@example.com", limit: 10, offset: 0) {
totalCount
items {
id
number
status
total {
value
currency
}
orderedAt
}
}
}
Example Response
{
"data": {
"getCustomerOrders": {
"totalCount": 2,
"items": [
{
"id": 123,
"number": "ORD-12345",
"status": "complete",
"total": {
"value": 99.99,
"currency": "USD"
},
"orderedAt": "2023-06-15T14:30:00Z"
},
{
"id": 124,
"number": "ORD-12346",
"status": "processing",
"total": {
"value": 149.99,
"currency": "USD"
},
"orderedAt": "2023-07-20T10:15:00Z"
}
]
}
}
}
Notes
- This query is intended for retrieving orders for a specific customer. For retrieving a single order by ID, use the
orderquery instead. - The
statusfield provides the current status of the order. The possible status values depend on the store's configuration. - The
orderedAtfield is a string representation of the date and time when the order was placed. The format follows the ISO 8601 standard. - If no orders are found,
itemsis empty andtotalCountis0. - For security reasons, this query should only be accessible to authenticated users retrieving their own orders, or to administrators with appropriate permissions.
- The implementation includes a TODO comment about authenticating the user first, indicating that additional authentication checks may be added in the future.