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

createCartFromOrder

Method that creates a cart based on the products ordered in a past order This method requires deleting the current cart, so that a new cart based on the given order can be put in its place.

This method sends a POST request to the createCartFromOrder endpoint of the Alokai Middleware. In turn, it exchanges data with the createCartFromOrder endpoint exposed by the SAP OCC API .

Signature

export declare function createCartFromOrder<Res extends CartModificationList = CartModificationList,
	Props extends CreateCartFromOrderProps = CreateCartFromOrderProps>(
	props: Props,
	options?: MethodOptions
): Promise<Res>;

Parameters

NameRequiredTypeDescription
propsRequiredPropsParameter 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 the operations applied to the new cart in order to make it the same as from the one in input

Referenced Types

Examples

Creating a new cart, which will contain products bought as part of a previous order

import { sdk } from '~/sdk';

const props = { orderCode: "00001234" };
await sdk.commerce.deleteCart({ cartId: "current"});
const cartModificationsList = await sdk.commerce.createCartFromOrder(props);

On this page