---
schema_version: "1"
id: d429dccaf0de140f7c17bd5628f7117e4e25e4a6b7dfd88152cbb3716b6a2196
title: Orders (History)
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/commerce-cloud/salesforce-commerce/guides/d2c-commerce/b2b-comm-headless-orders-history.md
canonical_url: https://developer.salesforce.com/docs/commerce/salesforce-commerce/guide/b2b-comm-headless-orders-history.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: e598c2495f332ac108e76bb428221cfdb43eb049713b85aaf926892bbf2ca721
products:
  - B2B Commerce Developer Guide
  - Salesforce APIs
---
# Orders (History)

### Overview

The Orders page displays a list of the buyer’s recent orders, including the order number, ordered date, order status, and order total for each entry. This page provides buyers with a centralized view of their order history and order status information.

This flow demonstrates how a headless storefront can render order history experiences using B2B Commerce Order Summary APIs.

![Orders History Buyer Journey](https://developer.salesforce.com/media/d2c-commerce/b2b-headless-b2b-commerce-headless-flow-orchestration-orders-history-buyer-journey-28-1.png '{"class": "image-lg", "title": "Orders History Buyer Journey"}')

### B2B Commerce APIs Used in the Flow

| Operation   | HTTP Method | Endpoint                                                                                                                                                                                   |
| ----------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| List orders | GET         | [`/commerce/webstores/{webstoreId}/order-summaries`](https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_commerce_webstore_order_summaries.htm) |

### Buyer Journey

#### Render Order History

1. Call the following endpoint to retrieve the buyer’s order history:

   GET [`/commerce/webstores/{webstoreId}/order-summaries?ownerScope=My&pageSize=50&fields=OrderNumber,OrderedDate,Status,TotalAmount,GrandTotalAmount,CurrencyIsoCode`](https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_commerce_webstore_order_summaries.htm)

2. Pass the fields query parameter explicitly. Some org configurations omit Grand Total Amount from the default response projection. Specifying the required fields explicitly ensures that the storefront receives all values needed for the order history page.

3. Use the response to retrieve the `orderSummaries` collection. The response returns order summaries sorted from newest to oldest.

4. Handle `403` and `404` responses as empty order-history states. Buyers without existing orders can receive these responses instead of an empty collection.

5. Read order summary fields defensively when rendering the response. Depending on org configuration, field values can appear in either of the following shapes:

   Flat field structure:

   ```json
   { "OrderNumber": "00001001" }
   ```

   Wrapped field structure:

   ```json
   { "fields": { "OrderNumber": { "text": "00001001" } } }
   ```

6. Check for both response shapes when rendering table cells to avoid displaying blank values for order details.

7. Use the response data to render:
   - Order number
   - Ordered date
   - Order status
   - Total amount
   - Grand total amount
   - Currency information

### Extend the Flow

- To add date-based filtering, pass the public `earliestDate` and `latestDate` query parameters in the [Order Summaries API](https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_commerce_webstore_order_summaries.htm) request.
- To add server-side pagination support, read the `pagination.nextPageToken` value returned in the API response and use it to retrieve the next set of order summaries.

## See Also

- [_B2B Commerce Developer Guide_: B2B Commerce Order Summary APIs](https://developer.salesforce.com/docs/commerce/salesforce-commerce/guide/b2b-d2c-comm-order-summaries-apis.html)
