OrderQuery
Description
Retrieves detailed information about a specific order by its ID or order number. This query allows you to fetch comprehensive order details including items, addresses, totals, and other order-related information.
Endpoint
query getOrder($id: Int, $number: String) {
getOrder(id: $id, number: $number) {
# Return fields
}
}
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
| id | Int | No | The unique identifier of the order to retrieve. Either id or number must be provided. |
| number | String | No | The order number (increment_id) of the order to retrieve. Either id or number must be provided. |
Return Values
The query returns an OrderDetail object 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. |
| billing_address | Address | The billing address associated with the order. |
| shipping_address | Address | The shipping address associated with the order. |
| total_item_count | Int | The total number of items in the order. |
| total_qty_ordered | Int | The total quantity of items ordered. |
| shipping_method | String | The shipping method used for the order. |
| shipping_amount | Float | The shipping cost for the order. |
| payment_method | String | The payment method used for the order. |
| payment_amount | Float | The payment amount for the order. |
| currency_code | String | The currency code used for the order (e.g., "USD"). |
| email_sent | Boolean | Indicates whether an order confirmation email was sent. |
| items | [OrderItem] | Array of items in the order. |
| orderedAt | String | The date and time when the order was placed. |
Address Structure
The billing_address and shipping_address fields contain:
| Field | Type | Description |
|---|---|---|
| firstname | String | First name. |
| lastname | String | Last name. |
| telephone | String | Phone number. |
| street | String | Street address. |
| city | String | City. |
| postcode | String | Postal or ZIP code. |
| country_code | String | Country code. |
| company | String | Company name, if applicable. |
| identification_number | String | Business identification number, if applicable. |
| tax_identification_number | String | Tax identification number, if applicable. |
OrderItem Structure
Each item in the items array contains:
| Field | Type | Description |
|---|---|---|
| id | Int! | Unique identifier for the order item. |
| sku | String! | The SKU of the product. |
| name | String! | The name of the product. |
| quantity | Int! | The quantity ordered. |
| custom | [CustomProperty] | Custom properties associated with the item. |
| total_weight | Float! | The total weight of the item. |
| base_weight | Float! | The base weight of the item. |
| price | Money | The price of a single unit. |
| row_total | Money | The total price for this item (quantity × price). |
Money Structure
Price fields use the Money structure:
| Field | Type | Description |
|---|---|---|
| value | Float! | The numerical value. |
| currency | String! | The currency code (e.g., "USD"). |
Usage Example
query {
getOrder(number: "ORD-12345") {
id
number
status
total {
value
currency
}
billing_address {
firstname
lastname
street
city
postcode
country_code
}
shipping_address {
firstname
lastname
street
city
postcode
country_code
}
items {
id
name
sku
quantity
price {
value
currency
}
row_total {
value
currency
}
}
shipping_method
payment_method
orderedAt
}
}
Example Response
{
"data": {
"getOrder": {
"id": 123,
"number": "ORD-12345",
"status": "complete",
"total": {
"value": 99.99,
"currency": "USD"
},
"billing_address": {
"firstname": "John",
"lastname": "Doe",
"street": "123 Main St",
"city": "Anytown",
"postcode": "12345",
"country_code": "US"
},
"shipping_address": {
"firstname": "John",
"lastname": "Doe",
"street": "123 Main St",
"city": "Anytown",
"postcode": "12345",
"country_code": "US"
},
"items": [
{
"id": 456,
"name": "Sample Product",
"sku": "product-123",
"quantity": 2,
"price": {
"value": 19.99,
"currency": "USD"
},
"row_total": {
"value": 39.98,
"currency": "USD"
}
},
{
"id": 457,
"name": "Another Product",
"sku": "product-456",
"quantity": 1,
"price": {
"value": 59.99,
"currency": "USD"
},
"row_total": {
"value": 59.99,
"currency": "USD"
}
}
],
"shipping_method": "flatrate_flatrate",
"payment_method": "checkmo",
"orderedAt": "2023-06-15T14:30:00Z"
}
}
}
Notes
- Either the
idornumberargument must be provided to identify the order. - If both
idandnumberare provided, the query will first attempt to find the order by ID, and if not found, it will try to find it by number. - If no order is found matching the provided criteria, an error will be thrown with the message "The requested order was not found."
- 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.