Alokai

addCustomerProductListItem

Adds an item to the customer's product list. Works for both registered and guest customers.

This method communicates with the createCustomerProductList endpoint of the Vue Storefront API Middleware. In turn, it receives data from the createCustomerProductList or the Create customer product list endpoints exposed by SCAPI / OCAPI depending on the middleware configuration.

Considered values from the request body are:

type → The type of the item to be added to the customer's product. Must be a valid type. Mandatory. list. priority → The priority of the item to be added to the customer's product list. public → The flag that determines whether the item to be added to the customer's product list is public. product_id → The ID (SKU) of the product related to the item to be added to the customer's product list. A valid product ID, used for product item type only. Must be a valid product ID; otherwise, a ProductListProductIdMissingException or ProductListProductNotFoundException is thrown. Mandatory when item type is product. quantity → Used for product item type only. This is the quantity of the item to be added to the customer's product list. You can also use a custom property of the form c_<CUSTOM_NAME>. The custom property must correspond to a custom attribute (<CUSTOM_NAME>) that is defined for ProductListItem. The value of this property must be valid for the type of custom attribute defined for ProductListItem.

Signature

export declare function addCustomerProductListItem(
	params: CreateCustomerProductListItemParams
): Promise<CustomerProductListItem>;

Parameters

NameRequiredTypeDescription
paramsRequiredCreateCustomerProductListItemParams

Returns

Returns a representation of a Product List Item.

Referenced Types

  • CreateCustomerProductListItemParams
  • CustomerProductListItem

Examples

Add an item to the current customer's wishlist.

import { sdk } from '~/sdk.config.ts';

const customer = await sdk.commerce.addCustomerProductListItem({
  type: 'wish_list'
});

Creating a custom product list with an item for the current customer.

import { sdk } from '~/sdk.config.ts';

const lists = await sdk.commerce.getCustomerProductLists();
const wishlist = lists.find((list) => list.type === 'wish_list');

const customer = await sdk.commerce.addCustomerProductListItem({
  listId: wishlist.id,
  productId: '123456',
});

On this page