Skip to content

Wishlist functions

This topic provides the details and instructions you need to use the functions provided by the wishlist drop-in component.

addProductsToWishlist

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.

Example usage

import { addProductsToWishlist } from '@/wishlist/api/addProductToWishlist';
addProductsToWishlist([{ sku: 'sku_item_1', quantity: 1 }]);

getProductBySku

The getProductBySku function retrieves product details based on the provided SKU.

Example function usage

import { getProductBySku } from '@/wishlist/api/addProductToWishlist';
getProductBySku('sku_item_1');

getStoreConfig

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

Example function usage

import { getStoreConfig } from '@/wishlist/api/getStoreConfig';
getStoreConfig();

getWishlistById

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

Example function usage

import { getWishlistById } from '@/wishlist/api/getWishlistById';
getWishlistById('1');

getWishlists

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

Example function usage

import { getWishlists } from '@/wishlist/api/getWishlists';
getWishlists();

mergeWishlists

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.

Example function usage

import { mergeWishlists } from '@/wishlist/api/mergeWishlists';
mergeWishlists(wishlist);

removeProductsFromWishlist

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

Example usage

import { removeProductsFromWishlist } from '@/wishlist/api/removeProductsFromWishlist';
removeProductsFromWishlist([{ product: { sku: 'sku_item_1' }}]);

updateProductsInWishlist

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

Example usage

import { updateProductsInWishlist } from '@/wishlist/api/updateProductsInWishlist';
updateProductsInWishlist([{ wishlistItemId: 'test-id', quantity: 1, description: 'Lorem ipsum' }]);