Skip to content

Wishlist Functions

The Wishlist drop-in provides API functions that enable you to programmatically control behavior, fetch data, and integrate with Adobe Commerce backend services.

Version: 3.1.0
FunctionDescription
addProductsToWishlistAdd products to a user’s wishlist.
getStoreConfigRetrieves the store configuration, which includes various settings and preferences for the store..
getWishlistByIdRetrieves a wishlist by its ID.
getWishlistsRetrieves all wishlists associated with a user.
initializeWishlistAPI function for the drop-in..
mergeWishlistsMerge a wishlist from local storage with one belonging to a registered user.
removeProductsFromWishlistRemove products from a user’s wishlist.
resetWishlistResets the wishlist by clearing the current wishlist ID and marking the user as unauthenticated.
updateProductsInWishlistUpdate the quantity of products in a user’s wishlist.

The addProductsToWishlist function allows you to add products to a user’s wishlist. This function is typically used when a user wants to save a product for later purchase. The function calls the addProductsToWishlist mutation.

const addProductsToWishlist = async (
items: [ { sku: string; quantity: number; optionsUIDs?: string[]; // should be the options available for the product enteredOptions?: { uid: string; value: string }[]; // refer to both selected and entered options } ]
): Promise<Wishlist | null>
ParameterTypeReq?Description
skustringYesThe product identifier (SKU) for the product. For configurable products (like a shirt available in multiple colors and sizes), use the child product SKU that represents the specific variant selected by the customer (e.g., `MS09-M-Blue for a medium blue shirt`).
quantitynumberYesThe number of items. This value must be a positive number.
optionsUIDsstring[]NoAn array of option UIDs for configurable products. These are the UIDs of the selected product options (such as color or size) that are selected. These represent the selected product variant. Use the product query to retrieve available option UIDs for a product.

Emits the wishlist/data event with the updated wishlist information after adding the products. This event may be emitted multiple times depending on the operation flow (e.g., creating a new wishlist, merging wishlists, or updating an existing wishlist).

Returns Wishlist or null.

The getStoreConfig function retrieves the store configuration, which includes various settings and preferences for the store.

const getStoreConfig = async (): Promise<StoreConfigModel | null>

Does not emit any drop-in events.

Returns StoreConfigModel or null.

The getWishlistById function retrieves a wishlist by its ID. This is useful for accessing a specific user’s wishlist. The function calls the wishlist_v2 query.

const getWishlistById = async (
wishlistId: string
): Promise<void | Wishlist | null>
ParameterTypeReq?Description
wishlistIdstringYesThe unique identifier of the wishlist to retrieve.

Emits the wishlist/data event with the retrieved wishlist information.

Returns void | Wishlist | null. See Wishlist.

The getWishlists function retrieves all wishlists associated with a user. This is useful for displaying all wishlists a user has created.

const getWishlists = async (): Promise<void | Wishlist[] | null>

Does not emit any drop-in events.

Returns void | Wishlist[] | null. See Wishlist.

const initializeWishlist = async (): Promise<Wishlist | null>

Emits the following events: wishlist/data, wishlist/initialized.

Returns Wishlist or null.

The mergeWishlists function allows you to merge a wishlist from local storage with one belonging to a registered user. This is useful when a user wants to synchronize both local and remote wishlists into one wishlist after logging in.

function mergeWishlists(wishlist: Wishlist): Promise<Wishlist | null>

The removeProductsFromWishlist function allows you to remove products from a user’s wishlist. The function calls the removeProductsFromWishlist mutation.

const removeProductsFromWishlist = async (
items: Array<Item>
): Promise<Wishlist | null>
ParameterTypeReq?Description
itemsArray<Item>YesAn array of wishlist item identifiers to remove from the wishlist.

Emits the wishlist/data event with the updated wishlist information after removing the products. This event may be emitted multiple times depending on whether the wishlist becomes empty after removal.

Returns Wishlist or null.

Resets the wishlist by clearing the current wishlist ID and marking the user as unauthenticated. It returns a promise that resolves to null.

const resetWishlist = async (): Promise<Wishlist | null>

Does not emit any drop-in events.

Returns Wishlist or null.

The updateProductsInWishlist function allows you to update the quantity of products in a user’s wishlist. The function calls the updateProductsInWishlist mutation.

const updateProductsInWishlist = async (
items: { wishlistItemId: string; quantity: number; description: string; selectedOptions?: string[]; enteredOptions?: { uid: string; value: string }[]; }[]
): Promise<Wishlist | null>
ParameterTypeReq?Description
wishlistItemIdstringYesThe unique identifier of the wishlist item to update. This ID is returned in the wishlist data structure when you retrieve a wishlist (not the product SKU). Each item in a wishlist has its own unique ID, even if multiple items reference the same product.
quantitynumberYesThe new quantity for the item. This replaces the current quantity (it does not increment). For example, setting this to `2` will change the quantity to 2, regardless of the previous value. This value must be a positive number.
descriptionstringYesA text description.
selectedOptionsstring[]NoAn array of option UIDs to update the selected product options for configurable products. For example, if a customer wants to change the size from **Medium** to **Large**, you would provide the UID for the Large option. These are the same type of option UIDs used when selecting product options.
enteredOptions{ uid: string; value: string }[]NoAn array of custom options that allow text input for customizable products. Each object contains a `uid` (the unique identifier for the custom option field from the product data) and a `value` (the text the customer entered). These are typically used for personalization like engravings or custom messages.

Does not emit any drop-in events.

Returns Wishlist or null.

The following data models are used by functions in this drop-in.

The StoreConfigModel object is returned by the following functions: getStoreConfig.

interface StoreConfigModel {
wishlistIsEnabled: boolean;
wishlistMaxNumber: number;
wishlistMultipleListIsEnabled: boolean;
}

The Wishlist object is returned by the following functions: addProductsToWishlist, getWishlistById, getWishlists, initializeWishlist, mergeWishlists, removeProductsFromWishlist, resetWishlist, updateProductsInWishlist.

interface Wishlist {
id: string;
updated_at: string;
sharing_code: string;
items_count: number;
items: Item[];
}