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

addCartEmail

Method assigning an email to the cart and initializing guest checkout in SAP Commerce Cloud.

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

In SAP Commerce Cloud, the sole purpose of assigning an email address to the cart is to initialize a guest checkout. Therefore, the addCartEmail() method works with anonymous carts only. It will not work when vsf-sap-token cookie is present in the browser.

Also, remember to pass cart guid as the cartId param.

Signature

export declare function addCartEmail<Props extends AddGuestEmailToCartProps = AddGuestEmailToCartProps>(
	props: Props,
	options?: MethodOptions
): Promise<void>;

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

This method does not return anything.

Referenced Types

Examples

Assigning email to the cart.

import { sdk } from '~/sdk';

const cartModification = await sdk.commerce.addCartEmail({
  cartId: '00035084',
  email: 'test@gmail.com'
});

On this page