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

saveCart

Turn an active user cart into a saved cart in SAP Commerce Cloud.

This method exchanges data with the doSaveCart 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 request). Also, make sure you are passing cart code (and not guid) as the cartId param.

Signature

export declare function saveCart(
	context: SapccIntegrationContext,
	props: SaveCartProps
): Promise<SaveCartResult>;

Parameters

NameRequiredTypeDescription
contextRequiredSapccIntegrationContext
propsRequiredSaveCartPropsParameter object which can be used with this method. Refer to its type definition to learn about possible properties.

Returns

Returns a representation of a Save Cart Result.

Referenced Types

Examples

Turning an active user cart into a saved cart.

import { sdk } from '~/sdk';

const savedCart = await sdk.commerce.saveCart({ cartId: '00035084' });

Turning an active user cart into a saved cart with name and description.

import { sdk } from '~/sdk';

const savedCart = await sdk.commerce.saveCart({
  cartId: '00035084',
  name: 'wishlist',
  description: 'This is a wishlist description'
});

Turning an active user cart into a saved cart and selecting response fields.

import { sdk } from '~/sdk';

const savedCart = await sdk.commerce.saveCart({
  cartId: '00035084',
  fields: 'savedCartData(code,name,savedBy(FULL))'
});

On this page