Alokai
You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x

getUserOrderHistory

Method fetching all customer orders placed for a specific Base Store in SAP Commerce Cloud.

This method sends a POST request to the getUserOrderHistory endpoint of the Alokai Middleware. In turn, it 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 browser for the method to work properly.

You might also want to see the getUserOrder method.

Signature

export declare function getUserOrderHistory<Res extends OrderHistoryList = OrderHistoryList,
	Props extends GetUserOrderHistoryProps = GetUserOrderHistoryProps>(
	props?: Props,
	options?: MethodOptions
): Promise<Res>;

Parameters

NameRequiredTypeDescription
propsOptionalPropsParameter object which can be used with this method. Refer to its type definition to learn about possible properties.
optionsOptionalMethodOptionsOptions that can be passed to additionally configure the request or customize the logic in a plugin.

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'
});

On this page