Skip to content

Favorites Actions

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.

Retrieves the items of one favorite list from the server.

import { fetchFavorites } from '@shopgate/engage/favorites';
dispatch(fetchFavorites());
  • ignoreCache (boolean): Indicates whether to ignore the cache.
  • listId (string): The ID of the list to retrieve. Defaults to the default list.

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());
  • ignoreCache (boolean): Indicates whether to ignore the cache.

An array of objects with an id and a name.


Retrieves the favorite lists of the user and the items of every list.

import { fetchFavoritesListsWithItems } from '@shopgate/engage/favorites';
dispatch(fetchFavoritesListsWithItems());
  • ignoreCache (boolean): Indicates whether to ignore the cache.

Creates a new favorite list.

import { addFavoritesList } from '@shopgate/engage/favorites';
dispatch(addFavoritesList('Birthday'));
  • name (string) required: The name of the new list.

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));

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 to true.

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.

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'));
  • 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.

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'));
  • productId (string) required: The ID of the product.
  • withRelatives (boolean): Indicates whether relatives are also removed.