You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x
addCartEmail
Assign an email to the cart and initialize guest checkout in SAP Commerce Cloud.
This method 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 request.
Also, remember to pass cart guid as the cartId param.
Signature
export declare function addCartEmail(
context: SapccIntegrationContext,
props: AddGuestEmailToCartProps
): Promise<void>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | SapccIntegrationContext | |
props | Required | AddGuestEmailToCartProps | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
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'
});