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

cloneCart

Method cloning a saved user cart in SAP Commerce Cloud.

This method sends a POST request to the cloneCart endpoint of the Alokai Middleware. In turn, it exchanges data with the doCartClone 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 cloneCart<Res extends SaveCartResult = SaveCartResult,
	Props extends SaveCartProps = SaveCartProps>(
	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 a representation of a Save Cart Result.

Referenced Types

Examples

Cloning a saved user cart.

import { sdk } from '~/sdk';

const clonedCart = await sdk.commerce.cloneCart({ cartId: '00035084' });

Cloning a saved user cart and giving it name and description.

import { sdk } from '~/sdk';

const clonedCart = await sdk.commerce.cloneCart({
  cartId: '00035084',
  name: 'cloned-cart-name',
  description: 'This is a cloned cart description'
});

Cloning a saved user cart and selecting response fields.

import { sdk } from '~/sdk';

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

On this page