Favorites Actions
- fetchFavorites
- fetchFavoritesLists
- fetchFavoritesListsWithItems
- addFavoritesList
- toggleFavorites
- toggleFavorite
- toggleFavoriteWithListChooser
All actions that address a single list take a list ID. When it is omitted, the action falls back to the default list, which is the only list in apps without support for multiple favorite lists. For an introduction to the feature, see the Favorite Lists guide.
fetchFavorites
Section titled “fetchFavorites”Retrieves the items of one favorite list from the server.
import { fetchFavorites } from '@shopgate/engage/favorites';
dispatch(fetchFavorites());Parameters
Section titled “Parameters”ignoreCache(boolean): Indicates whether to ignore the cache.listId(string): The ID of the list to retrieve. Defaults to the default list.
fetchFavoritesLists
Section titled “fetchFavoritesLists”Retrieves the favorite lists of the user, without their items. In apps without support for multiple favorite lists, the action does not send a request and returns a single list with the ID DEFAULT instead.
import { fetchFavoritesLists } from '@shopgate/engage/favorites';
dispatch(fetchFavoritesLists());Parameters
Section titled “Parameters”ignoreCache(boolean): Indicates whether to ignore the cache.
Returns
Section titled “Returns”An array of objects with an id and a name.
fetchFavoritesListsWithItems
Section titled “fetchFavoritesListsWithItems”Retrieves the favorite lists of the user and the items of every list.
import { fetchFavoritesListsWithItems } from '@shopgate/engage/favorites';
dispatch(fetchFavoritesListsWithItems());Parameters
Section titled “Parameters”ignoreCache(boolean): Indicates whether to ignore the cache.
addFavoritesList
Section titled “addFavoritesList”Creates a new favorite list.
import { addFavoritesList } from '@shopgate/engage/favorites';
dispatch(addFavoritesList('Birthday'));Parameters
Section titled “Parameters”name(string) required: The name of the new list.
toggleFavorites
Section titled “toggleFavorites”Contains the addFavorites and removeFavorites functions. addFavorites is deprecated starting from Engage Theme version 6.7.0 and has been replaced with the addFavorite action.
import { addFavorite, removeFavorites } from '@shopgate/engage/favorites';
const productId = '25';const listId = '1';const withRelatives = false;
dispatch(addFavorite(productId, listId));dispatch(removeFavorites(productId, withRelatives, listId));Parameters
Section titled “Parameters”addFavorite
productId(string) required: The ID of the product to add.listId(string): The ID of the list to add the product to. Defaults to the default list.quantity(number): The quantity to store with the product. Only sent when the quantity setting is enabled for the app.notes(string): A note to store with the product. Only sent when the notes setting is enabled for the app.showToast(boolean): Whether a confirmation toast is shown after the product was added. Defaults totrue.
removeFavorites
productId(string) required: The ID of the product to remove.withRelatives(boolean): Indicates whether relatives are also removed.listId(string): The ID of the list to remove the product from. Defaults to the default list.
toggleFavorite
Section titled “toggleFavorite”Adds the product to a list, or removes it when it is already on that list.
import { toggleFavorite } from '@shopgate/engage/favorites';
dispatch(toggleFavorite('25', '1'));Parameters
Section titled “Parameters”productId(string) required: The ID of the product.listId(string): The ID of the list. Defaults to the default list.withRelatives(boolean): Indicates whether relatives are also removed.
toggleFavoriteWithListChooser
Section titled “toggleFavoriteWithListChooser”Behaves like toggleFavorite, but opens the list chooser when the user has more than one list, so that the user selects the target list. Use this action for the favorite button of a product.
import { toggleFavoriteWithListChooser } from '@shopgate/engage/favorites';
dispatch(toggleFavoriteWithListChooser('25'));Parameters
Section titled “Parameters”productId(string) required: The ID of the product.withRelatives(boolean): Indicates whether relatives are also removed.

