Salesforce Commerce Wishlists API
The Salesforce Commerce Wishlists API allows customers to manage their Wishlists. Wishlists provide customers with a convenient way to save or bookmark products they are interested in. For example, while browsing for products, customers can add items to their Wishlists for future reference. Wishlists are available in both B2B and D2C stores.
There are six Wishlist-related APIs—some manage Wishlists, while others handle individual items. These APIs allow you to add products to new or existing Wishlist, delete Wishlist items, add Wishlist items to a cart, or move all items from a cart to a Wishlist. Although the Lightning Web Runtime (LWR) template doesn't support moving all Wishlist items to a specific cart in the UI, you can use the API to create a custom solution for this.
The Commerce Webstore Wishlists API can be used to retrieve a list of Wishlists or to create a new Wishlist for a user. The GET method retrieves the details of the user's Wishlists but does not include associated products by default. You can use the includeDisplayedList request parameter to fetch complete details of the oldest Wishlist, including associated items and their related data (such as fields and images). However, to fetch complete details about a particular WishList, pass the wishListId request parameter. The POST method allows you to create a new Wishlist by providing the Wishlist name and the IDs of the products you want to associate with it.
The Commerce Webstore Wishlist API allows you to update, delete, or retrieve a specific Wishlist. The GET method fetches complete details of the specified Wishlist, including associated items and their related data. The PATCH method is limited to updating only the Wishlist's name, without support for modifying any other attributes. To delete a specific Wishlist, the DELETE method can be used.
For managing individual Wishlist items, the Commerce Webstore Wishlist Item API provides functionality to delete a single item. The DELETE method allows you to remove a specific item from a Wishlist.
The Commerce Webstore Wishlist Items API allows you to add items to a Wishlist or retrieve them. The GET method retrieves items from a specified Wishlist, while the POST method adds a single product to an existing Wishlist. Typically used on the Product Detail Page, this API enables users to bookmark a product by adding it to one of their existing Wishlists.
The Commerce Webstore Wishlist, Add To Cart API allows you to move all products from a Wishlist to an active and specific cart. For example, if you're on the Wishlist page and want to add all items from a Wishlist to a cart, you can make a POST request to move the items to the desired cart. Currently, the Lightning Web Runtime (LWR) experience builder site does not support adding Wishlist items to a specific cart through the user interface. However, if customers are creating their own custom experience, they can use this API to build an action that adds all items from a Wishlist to an active cart.
The Commerce Webstore Cart, Add To Wishlist API enables users to move products from their active and specific cart to an existing Wishlist. This API functions exclusively within the cart, allowing users to move all items from the cart to a specified Wishlist using the POST method.
Let's consider a basic scenario for building a flow using Wishlists APIs. This example covers just a few Wishlists APIs and doesn't include the entire APIs functionality.
Imagine a scenario where a buyer is on the Product Detail page and wants to bookmark a product for future reference. In this case, they would make a POST request to the Commerce Webstore Wishlist Items API to add the product to an existing Wishlist. Later, if the buyer decides to remove a specific product from their Wishlist, they would send a DELETE request to the Commerce Webstore Wishlist Item API to remove that item.
Consider a scenario where a customer adds multiple items to their cart but decides to complete the purchase at a later time. For instance, on a shopping site, the customer can add products directly to your cart, and if you change your mind, you can move those products to your Wishlist for later reference. In this case, you can make a POST request to the Commerce Webstore Cart, Add To Wishlist API to transfer products from your active cart to an existing Wishlist.
Here’s a list of Commerce Wishlists resources:
Resource | Supported HTTP Methods | Description |
---|---|---|
/commerce/webstores/{webstoreId}/wishlists | GET, POST | Create a new WishList or fetch collection of WishList. |
/commerce/webstores/{webstoreId}/wishlists/{wishlistId} | DELETE, GET, PATCH | Delete, edit, or fetch a specific WishList. |
/commerce/webstores/{webstoreId}/wishlists/{wishlistId}/actions/add-wishlist-to-cart | POST | Add all products from WishList to the provided Cart. |
/commerce/webstores/{webstoreId}/wishlists/{wishlistId}/wishlist-items | GET, POST | Get wishlist items or add items to the wishlist. |
/commerce/webstores/{webstoreId}/wishlists/{wishlistId}/wishlist-items/{wishlistItemId} | DELETE | Delete single WishList item. |
/commerce/webstores/{webstoreId}/carts/cartStateOrId/actions/add-cart-to-wishlist | POST | Copy products from Cart to WishList. |