getUserOrderHistory
Get all customer orders placed for a specific Base Store in SAP Commerce Cloud.
This method exchanges data with the getUserOrderHistory endpoint exposed by the SAP OCC API Orders Controller.
The method fetches an order history based on the vsf-sap-token cookie (which is assigned to that customer). The cookie must be present in the request for the method to work properly.
Signature
export declare function getUserOrderHistory(
context: SapccIntegrationContext,
props?: GetUserOrderHistoryProps
): Promise<OrderHistoryList>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | SapccIntegrationContext | |
props | Optional | GetUserOrderHistoryProps | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
Returns
Returns a representation of an Order History List.
Referenced Types
Examples
Fetching an order history for the currently logged-in customer.
import { sdk } from '~/sdk';
const orderHistory = await sdk.commerce.getUserOrderHistory();Fetching an order history for the currently logged-in customer and selecting response fields.
import { sdk } from '~/sdk';
const orderHistory = await sdk.commerce.getUserOrderHistory({
fields: 'orders(code,status)'
});Fetching a paginated order history for the currently logged-in customer. The default values for the pageSize and currentPage parameters are 0 and 20 respectively.
import { sdk } from '~/sdk';
const orderHistory = await sdk.commerce.getUserOrderHistory({
pageSize: 3,
currentPage: 1
});Fetching a filtered order history for the currently logged-in customer. The param is a comma-separated list of available order statuses.
import { ORDER_STATUSES } from '@vsf-enterprise/sapcc-types;
import { sdk } from '~/sdk';
const { CANCELLED, CHECKED_VALID } = ORDER_STATUSES;
const orderHistory = await sdk.commerce.getUserOrderHistory({
statuses: `${CANCELLED},${CHECKED_VALID}`
});Fetching a sorted order history for the currently logged-in customer. By default, the results are sorted byDate.
import { sdk } from '~/sdk';
const orderHistory = await sdk.commerce.getUserOrderHistory({
sort: 'byOrderNumber'
});