Remove an item from wishlist without including wishlist web part

   —   
Remove an item from wishlist without including wishlist web part
By default, when you want to use GetRemoveFromWishListLink function in your transformation to remove items from a wishlist, it is necessary to place the wishlist web part on the same page, otherwise the function will not work.  In order to change this behaviour and be able to use GetRemoveFromWishListLink function without the need of including wishlist web part on the page, add the following code to the ASCX transformation:
<script runat=server> protected void tstButton_Command(object sender, CommandEventArgs e) { int siteId = CMS.CMSHelper.CMSContext.CurrentSiteID; int userId = CMS.CMSHelper.CMSContext.CurrentUser.UserID; int skuId = CMS.GlobalHelper.ValidationHelper.GetInteger(e.CommandArgument, 0); if(CMS.Ecommerce.WishlistItemInfoProvider.GetWishlistItemInfo(userId, skuId, siteId) != null) { CMS.Ecommerce.WishlistItemInfoProvider.RemoveSKUFromWishlist(userId, skuId, siteId); } } </script> <asp:LinkButton runat="server" ID="tstButton" CommandName="RemoveWishlist" OnCommand="tstButton_Command" CommandArgument='<%# EvalInteger("SKUID") %>'>Remove from wishlist</asp:LinkButton>

At this point, after you click the link you should be able to remove the items from wishlist.

-RK-


Applies to: Kentico 7.x
Share this article on   LinkedIn