restoreCart
Method turning a saved user cart into an active user cart in SAP Commerce Cloud.
This method sends a POST request to the restoreCart endpoint of the Alokai Middleware. In turn, it exchanges data with the doUpdateSavedCart endpoint exposed by the SAP OCC API Save Cart Controller.
This method works only in an authenticated user session (i.e. when the vsf-sap-token cookie is present in the browser). Also, make sure you are passing cart code (and not guid) as the cartId param.
Signature
export declare function restoreCart<Res extends SaveCartResult = SaveCartResult,
Props extends RestoreCartProps = RestoreCartProps>(
props: Props,
options?: MethodOptions
): Promise<Res>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Required | Props | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
options | Optional | MethodOptions | Options that can be passed to additionally configure the request or customize the logic in a plugin. |
Returns
Returns a representation of a Save Cart Result.
Referenced Types
Examples
Restoring a saved user cart.
import { sdk } from '~/sdk';
const restoredCart = await sdk.commerce.restoreCart({ cartId: '00035084' });Restoring a saved user cart and selecting response fields.
``ts import { sdk } from '~/sdk';
const restoredCart = await sdk.commerce.restoreCart({ cartId: '00035084', fields: 'savedCartData(code,savedBy(FULL),user(FULL))' });