/// <summary> /// Removes product from wishlist. /// </summary> private void btnRemoveProduct_Click(object sender, EventArgs e) { if ((currentUser != null) && (currentSite != null)) { // Remove specified product from the user's wishlist WishlistItemInfoProvider.RemoveSKUFromWishlist(currentUser.UserID, ValidationHelper.GetInteger(hidProductID.Value, 0), currentSite.SiteID); LoadData(); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { currentUser = MembershipContext.AuthenticatedUser; if (AuthenticationHelper.IsAuthenticated()) { // Control initialization lblTitle.Text = GetString("Ecommerce.Wishlist.Title"); btnContinue.Text = GetString("Ecommerce.Wishlist.btnContinue"); mSKUId = QueryHelper.GetInteger("productID", 0); currentSite = SiteContext.CurrentSite; // Set repeater transformation repeater.TransformationName = TransformationName; repeater.ItemSeparator = ItemSeparator; if ((currentUser != null) && (currentSite != null)) { if ((!RequestHelper.IsPostBack()) && (mSKUId > 0)) { int addSKUId = mSKUId; // Get added SKU info object from database SKUInfo skuObj = SKUInfoProvider.GetSKUInfo(addSKUId); if (skuObj != null) { // Can not add option as a product if (skuObj.SKUOptionCategoryID > 0) { addSKUId = 0; } else if (!skuObj.IsGlobal) { // Site specific product must belong to the current site if (skuObj.SKUSiteID != currentSite.SiteID) { addSKUId = 0; } } else { // Global products must be allowed when adding global product if (!ECommerceSettings.AllowGlobalProducts(currentSite.SiteName)) { addSKUId = 0; } } } if (addSKUId > 0) { // Add specified product to the user's wishlist WishlistItemInfoProvider.AddSKUToWishlist(currentUser.UserID, addSKUId, currentSite.SiteID); LogProductAddedToWLActivity(addSKUId, ResHelper.LocalizeString(skuObj.SKUName)); } } if (mSKUId > 0) { // Remove product parameter from URL to avoid adding it next time string newUrl = URLHelper.RemoveParameterFromUrl(RequestContext.CurrentURL, "productID"); URLHelper.Redirect(newUrl); } } } else { // Hide control if current user is not authenticated Visible = false; } } }