Skip to main content
Version: 1.0.0

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

ArgumentTypeRequiredDescription
idIntNoThe unique identifier of the order to retrieve. Either id or number must be provided.
numberStringNoThe 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:

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.
billing_addressAddressThe billing address associated with the order.
shipping_addressAddressThe shipping address associated with the order.
total_item_countIntThe total number of items in the order.
total_qty_orderedIntThe total quantity of items ordered.
shipping_methodStringThe shipping method used for the order.
shipping_amountFloatThe shipping cost for the order.
payment_methodStringThe payment method used for the order.
payment_amountFloatThe payment amount for the order.
currency_codeStringThe currency code used for the order (e.g., "USD").
email_sentBooleanIndicates whether an order confirmation email was sent.
items[OrderItem]Array of items in the order.
orderedAtStringThe date and time when the order was placed.

Address Structure

The billing_address and shipping_address fields contain:

FieldTypeDescription
firstnameStringFirst name.
lastnameStringLast name.
telephoneStringPhone number.
streetStringStreet address.
cityStringCity.
postcodeStringPostal or ZIP code.
country_codeStringCountry code.
companyStringCompany name, if applicable.
identification_numberStringBusiness identification number, if applicable.
tax_identification_numberStringTax identification number, if applicable.

OrderItem Structure

Each item in the items array contains:

FieldTypeDescription
idInt!Unique identifier for the order item.
skuString!The SKU of the product.
nameString!The name of the product.
quantityInt!The quantity ordered.
custom[CustomProperty]Custom properties associated with the item.
total_weightFloat!The total weight of the item.
base_weightFloat!The base weight of the item.
priceMoneyThe price of a single unit.
row_totalMoneyThe total price for this item (quantity × price).

Money Structure

Price fields use the Money structure:

FieldTypeDescription
valueFloat!The numerical value.
currencyString!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 id or number argument must be provided to identify the order.
  • If both id and number are 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.