Salesforce Commerce Order Summary APIs
The Salesforce Commerce Order Summary APIs allow users to manage their order summaries for placed orders. With these APIs, they can retrieve past order summaries, view details of a specific order summary, reorder from an existing order summary, and submit asynchronous jobs to calculate adjustment aggregates for multiple order summaries.
To retrieve order summaries, use the Commerce Webstore Order Summaries API. This API fetches order summaries based on a specified account ID. If an account ID isn’t provided as a query parameter, the API defaults to the user’s context and returns order summaries relevant to them. For B2B users, the API supports an account switch feature, enabling access to order summaries from multiple accounts by using the effective account ID parameter. D2C users only view order summaries associated with their current account.
This API is currently utilized on the Order History page in the out-of-the-box experience, enabling users to view their order summaries. With pagination support, users can seamlessly navigate through additional results using the “Next” function. By default, order summaries are sorted in descending order by creation date, showing the most recent orders first. In Lightning Web Runtime (LWR) templates, only the most recent order summary is shown first, while Aura templates provide sorting flexibility, allowing to show either the oldest or the most recent order summary at the top of the results page.
To view the details of a specific order summary, including all associated line items and relevant order amount fields, use the Commerce Webstore Order Summary Lookup API. This API provides details such as the grand total, promotion amount, and coupon amount, reflecting the total adjustments applied. It also returns item images, associated shipping addresses, and the corresponding line items for each address.
This API fetches all line items grouped by shipping addresses. The out-of-the-box solution provides UI-level pagination, but the API doesn’t support pagination for custom implementations. To exclude certain details in the API response, use query parameters like excludeDeliveryGroups
, excludeAdjustments
, and excludeAdjustmentAggregates
.
Guest users can access this API by including the verification parameter in the Order Summary Lookup Input. For guests, the order reference number in the orderSummaryIdOrRefNumber
parameter is mandatory and accepts order reference number (for guests) and Salesforce order summary record ID (for authenticated users). Guest user verification requires a combination of email and phone numbers, with last name as an optional field. Authenticated users, however, are not required to provide verification.
For B2B users, the API supports an account switch feature, enabling access to order summaries from multiple accounts by specifying the effective account ID parameter. D2C users can only view order summaries associated with their current account.
To reorder from an existing order summary, use the Commerce Webstore Order Summaries Add Order to Cart API. This API simplifies the reorder process by adding all items from a specified order summary directly to your current cart. For example, as a store owner needing regular inventory replenishment, you can revisit a previous order summary and reorder all items with ease. If no active cart exists, the API creates a new cart and adds the items. This API supports both authenticated and guest users. However, guest users must complete a verification process by providing their last name, email address, and phone number. To retrieve an order summary, use the Commerce Webstore Order Summary API with the order summary ID. To view delivery groups associated with an order summary, use the Commerce Webstore Order Delivery Groups API. For details about items in an order summary, leverage the Commerce Webstore Order Items API. These APIs are designed for registered buyers and are not accessible to guest users.
To retrieve shipment information for a generated order summary, submit a GET request to the Commerce Webstore Order Shipments API. To retrieve order items associated with a specific shipment, use the Commerce Webstore Shipment Items API with the shipment ID. Both of these APIs are restricted to authenticated users and are not accessible to guest users.
To submit a job to recalculate adjustment aggregates for a list of order summary IDs, use the Commerce Webstore Order Summaries, Adjustment Aggregates API. Order summaries include various types of adjustments, such as promotional and coupon-related adjustments. This adjustment data is added to the OrderSummaryAdjustmentAggregates entity. If the adjustment calculations fail for certain order summaries, their values default to null or zero. This API enables administrators to manually recalculate these adjustment values. As an asynchronous API, it allows admin users to submit a list of order summaries for calculating adjustment values.
Let's consider a basic scenario for building a flow using Order Summary resources. This example covers just a few resources and doesn't include the entire API functionality.
Imagine you manage an online store, and a regular B2B customer frequently reorders the same set of supplies each month. To simplify their experience, you implement the Commerce Webstore Order Summaries Add Order to Cart API. With this functionality, the customer can view their past order summaries on their order history page and quickly reorder with one click. Upon reordering, the API automatically adds all items from the previous order summary to their cart, thereby saving time and effort.
Here’s a list of Order Summary resources:
Resource | Supported HTTP Methods | Description |
---|---|---|
/commerce/webstores/webstoreId/order-summaries/actions/lookup | POST | Look up details about an OrderSummary for a guest shopper or a registered buyer. |
/commerce/webstores/${webstoreId}/order-summaries | GET | Get order summaries for registered buyers. |
/commerce/webstores/webstoreId/order-summaries/orderSummaryId/actions/add-order-to-cart | POST | Use a webstore’s order summary to add an order to a cart. |
/commerce/webstores/webstoreId/order-summaries/orderSummaryId | GET | Get an order summary for a provided order summary ID. |
/commerce/webstores/webstoreId/order-summaries/orderSummaryId/delivery-groups | GET | Get order delivery groups for a provided order summary ID. |
/commerce/webstores/webstoreId/order-summaries/orderSummaryId/items | GET | Get order items for a specified order summary ID. |
/commerce/webstores/webstoreId/order-summaries/orderSummaryId/shipments | GET | Get order shipments for a specified order summary ID. |
/commerce/webstores/webstoreId/shipments/shipmentId/items | GET | Get shipment items for a provided shipment ID. |
/commerce/webstores/webstoreId/order-summaries/async-actions/adjustment-aggregates | POST | Submit a job to calculate adjustment aggregates for a list of order summary IDs. This API is available only to an administrator. |