Skip to main content
Version: 1.0.0

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

ArgumentTypeRequiredDescription
emailStringNoThe 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:

FieldTypeDescription
idIntThe unique identifier for the order.
numberStringThe order number or increment ID, typically used as a reference number for customers.
statusStringThe current status of the order (e.g., "pending", "processing", "complete", "canceled").
totalMoneyThe total amount of the order.
orderedAtStringThe date and time when the order was placed.

Money Structure

The total field uses the Money structure:

FieldTypeDescription
valueFloat!The numerical value of the amount.
currencyString!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 order query instead.
  • The status field provides the current status of the order. The possible status values depend on the store's configuration.
  • The orderedAt field 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.