Use the WishlistAdder class

The WishlistAdder class allows you to easily add products and their variations to a desired wish list. To do this, you must perform the following:

  1. Get the catalog manager.
    Get an instance of the CatalogManager object.
  2. Get the product.
    Get the specified product that you want to add to the wish list.
    For more information, read For developers: Query products.
  3. Get the variation.
    Get the specified variation of the product.
    For more information, read For developers: Query product variations. If you do not want to add a variation, skip this step.
  4. Create an instance of the OptionDetails class.
    The OptionDetails class will wrap the information about the variation. If you are do not want to add a variation to the wish list, don’t set any of the properties of the OptionDetails instance. For more information about how to set the properties of the OptionDetails instance, refer to the code example at the end of the article.
  5. Get the default currency.
    Get the name of the default currency from the Ecommerce configuration.
  6. Create an instance of the WishlistAdder class.
  7. Add the item to the wish list.
    To add the specified product to the wish list, call the AddItemToWishlist of the WishlistAdder instance. As argument pass the product, the instance of the OptionDetails class, the desired quantity, the default currency name and the ID of the user that the wish list belongs to.

Use the following code sample:

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?