GraphQL Storefront API: Orders
Overview
The GraphQL Storefront orders object schema can power requests to your headless storefront or Stencil theme supplying you with instant access to your Orders storefront data. To learn more about how the BigCommerce Storefront graph works, see GraphQL Storefront API overview.
In this document, you can learn how to use queries and operation types to fetch order data using the BigCommerce Storefront graph. Create arguments for fields like filtering orders by entity_Id. You’re encouraged to read on and put these example queries into practice by using the BigCommerce GraphQL Playground.
Fetch orders detail
Use the orders object type to fetch data in order to display the orders and details on the storefront graph.
Use the GetAllOrders query field to fetch all orders for a specific customer. You can get a customer’s order history, and get details like:
- Billing address, including the customer’s details
- Order status
- Consignment orders information
- Specific discounts, and coupons (when applied)
- Pricing
The following features are coming soon
- Payment/Payments information
- Order specific messages
Fetch order details
Use the order object type to get detailed information on the storefront graph.
Use the GetOrderDetails field query to fetch order details like:
- Specific customer orders
- Specific order data filtered by date, or status
Note: Don’t forget to include cursor pagination to refine the fetched information.
Authorization
Use your bearer token to perform the example queries on your storefront instance in the next section.
To learn more about authenticating requests to the GraphQL Storefront API, see Authenticating requests to the GraphQL Storefront API.
Example queries
Before running the example queries, you will need to sign in as a customer for the queries to work.
Get all orders and details
Filter by order status
In this example, the query is set up to return a filtered list of all orders with a COMPLETED status.
Request
Response
Get order details
In this example, the query gets details for order #106. Use entityId to query by order. Authorized B2B company users can retrieve order details for orders placed by other company users on the current storefront channel. The B2B order fields require a B2B storefront token.
Request
Response
Physical line items return downloadPageUrl only when the item bundles a downloadable digital product and the order’s digital products are available for download. Otherwise, as in this example, the field is null.
Get company orders
In this example, the query returns a page of orders placed on the current storefront channel by any user in the customer’s active company. The sortBy argument uses the CompanyOrdersSortInput enum to sort the orders from newest to oldest.
Request
Response
Get an order metafield
In this example, the query is set up to get a metafield for order #102. Use entityId to query by order.
Request
Response
Get metafields for a customer
In this example, the query is set up to get metafields for a customer. Ensure the customer is logged-in.
Request
Response
Join our Developer community to share your feedback with us in the BigCommerceDevs Slack.
Resources
Documentation
- GraphQL storefront API overview
- Guide to API Accounts: Store-level API accounts
- Guide to API accounts: OAuth token creation scopes
- Authentication and example requests: BigCommerce-generated JWTs