Developer forum

Forum » Ecommerce - Standard features » Add to list - in product detail

Add to list - in product detail

Nuno Aguiar
Reply

Hi,

 

We need to implement "add to wishlist" + "add to favorites" in a product detail page. I need the best approach to do this:

  • Since there are 2 lists, we need to create them beforehand.
    When the user registers, we immediatly create both lists to later add a product to them accordingly
     
  • When we are on the product detail page, there does not seem to be a "clear" way to determine that
foreach (LoopItem type in GetLoop("CustomerCenter.Lists.Type."))
{  @* Printscreen attached - YES the loop has '.' in the name *@
 
 foreach (LoopItem list in type.GetLoop("CustomerCenter.ProductLists"))
  {
    @* We check whether the product already belongs to one of the lists *@
    if(list.GetString("Ecom:CustomerCenter.List.Name") == "wishlist" && list.GetBoolean("Ecom:Product.List.IsProductInThisList")){
        bol_inListWishlist = true;
    }
    else if(list.GetString("Ecom:CustomerCenter.List.Name") == "favorites" && list.GetBoolean("Ecom:Product.List.IsProductInThisList")){
        bol_inListFavorite = true;
    }
  }
  foreach (LoopItem listType in type.GetLoop("CustomerCenter.ListTypes.Lists"))
  {
    @* We only got the tag when loading the TemplateTags *@
    var str_test = listType.TemplateTags("Ecom:CustomerCenter.ListTypes.List.");
    if(listType.GetString("Ecom:CustomerCenter.ListTypes.List.Name") == "favorites"){
      str_favoritesId = listType.GetString("Ecom:CustomerCenter.ListTypes.List.ID");
    }
    else {
      str_wishlistId = listType.GetString("Ecom:CustomerCenter.ListTypes.List.ID");
    }
  }
}

 

We need to do the above to get both the wishlistListID and the favoritesListID to built the addToWhishlist/RemoveFromWhishlist and addToFavorites/RemoverFromFavorites URL.

 

Is this the best approach? Does not seem "clean" to me.

 

Best Regards,

Nuno

ps.png

Replies

 

You must be logged in to post in the forum