Orders
Introduction
Working with orders in the B2B GraphQL API is fairly straightforward. The storefront experience of placing an order, for both B2B and B2C customers, relies on the BigCommerce checkout or use of the standard BigCommerce APIs. Therefore, the GraphQL Storefront API only handles the use case of fetching the details of a company’s existing orders and ordered products.
The order-related queries are available to any of the built-in user roles, or a custom role with the “Orders - View” permission.
Fetching Company Orders
The current company’s orders can be fetched with the allOrders query.
Example query and response:
Query
Response
allOrderssupports typical pagination arguments.- Other available filtering arguments include
beginDateAtandendDateAt, which accept date string values like “2025-01-01”. - The order fields include both B2B entity IDs (
idanduserId) and core BigCommerce IDs (bcOrderIdandbcCustomerId) of both the order records and associated customer/user records. - Note that despite the field name,
companyIdcontains a company object on which specific fields must be queried. itemscontains a count of the total items in the order. While this query doesn’t expose a field that returns an array of the order items, note thatproductscontains an encoded JSON string of the full BigCommerce order product details, which can be decoded in your application.- Similar to
products,shippingAddress,shipments, andcustomercontain JSON strings with full details of the shipping address, shipments (if any), and the associated customer record.
Fetching a Single Order
A single order’s details can be fetched with the order query using the order’s BigCommerce ID.
Example query, variables, and response:
Query
Variables
Response
Note that order returns a different GraphQL type than the nodes returned by allOrders, and in this case more granular details about the order can be queried than with the “list” query.
Many fields have been truncated from the above example, but note the following details:
- If the order originated with a quote, whether the negotiated discount will be represented as an order discount or reflected in the item prices/subtotal depends on the type of discount that was applied.
- The product
pricetax_field contains the amount of tax based on the item’s non-discounted price, whiletotaltax_contains the final tax amount. products,billingAddress,shippingAddress, andshipmentsreturn complex objects, but their GraphQL types do not allow more granular querying of their sub-fields.orderHistoryEventcontains a history of the order’s status changes.
Inspecting Ordered Products
With the orderedProducts query, historical information about a company’s previously ordered products can be queried, including the number of times ordered and first/last ordered dates.
Example query and response:
Query
Response
orderedProductssupports standard pagination arguments.- The query can also be filtered by the number of times a product has been ordered, using the
minOrderedTimesandmaxOrderedTimesarguments. - The query can also be filtered by the order date range, using the
beginDateAtandendDateAtarguments. These arguments accept a date string like “2025-01-01”.