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

createCartDeliveryAddress

Create address and assign it to the cart as delivery address in SAP Commerce Cloud.

This method exchanges data with the createCartDeliveryAddress endpoint exposed by the SAP OCC API Cart Addresses Controller.

This method will only work for either a current user cart or a guest cart (i.e. cart with an email added to it). It will not work with an anonymous cart. In case of a guest cart, remember to pass cart guid as the cartId param. In case of a current user cart, pass cart code instead.

Signature

export declare function createCartDeliveryAddress(
	context: SapccIntegrationContext,
	props: CreateCartAddressProps
): Promise<Address>;

Parameters

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

Returns

Returns a representation of an Address.

Referenced Types

Examples

Creating a delivery address for a cart.

import { sdk } from '~/sdk';

const cartAddress = await sdk.commerce.createCartDeliveryAddress({
  cartId: '00035084',
  address: {
    titleCode: 'mr',
    firstName: 'John',
    lastName: 'Doe',
    line1: 'Some Street',
    postalCode: '54-022',
    country: { isocode: 'GB' },
    town: 'Radom'
  }
});

Creating a delivery address for a cart and selecting response fields.

import { sdk } from '~/sdk';

const cartAddress = await sdk.commerce.createCartDeliveryAddress({
  cartId: '00035084',
  address: {
    titleCode: 'mr',
    firstName: 'John',
    lastName: 'Doe',
    line1: 'Some Street',
    postalCode: '54-022',
    country: { isocode: 'GB' },
    town: 'Radom'
  },
  fields: 'firstName,lastName,town'
});

On this page