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) {
getCustomerOrders(email: $email) {
# Return fields
}
}
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. |
Return Values
The query returns an array of Order objects with the following fields:
| 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") {
id
number
status
total {
value
currency
}
orderedAt
}
}
Example Response
{
"data": {
"getCustomerOrders": [
{
"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 for the specified email, an empty array will be returned.
- 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.