private void btnAddProduct_Click(object sender, EventArgs e) { // Do not add item if order is paid if (OrderIsPaid) { return; } // Get strings with productIDs and quantities separated by ';' string productIDs = ValidationHelper.GetString(hidProductID.Value, ""); string quantities = ValidationHelper.GetString(hidQuantity.Value, ""); string options = ValidationHelper.GetString(hidOptions.Value, ""); double price = ValidationHelper.GetDouble(hdnPrice.Value, -1); bool isPrivate = ValidationHelper.GetBoolean(hdnIsPrivate.Value, false); // Add new products to shopping cart if ((productIDs != "") && (quantities != "")) { int[] arrID = ValidationHelper.GetIntegers(productIDs.TrimEnd(';').Split(';'), 0); int[] arrQuant = ValidationHelper.GetIntegers(quantities.TrimEnd(';').Split(';'), 0); int[] intOptions = ValidationHelper.GetIntegers(options.Split(','), 0); // Check site binding if (!CheckSiteBinding(arrID) || !CheckSiteBinding(intOptions)) { return; } lblError.Text = ""; for (int i = 0; i < arrID.Length; i++) { int skuId = arrID[i]; SKUInfo skuInfo = SKUInfoProvider.GetSKUInfo(skuId); if ((skuInfo != null) && !skuInfo.IsProductOption) { int quantity = arrQuant[i]; ShoppingCartItemParameters cartItemParams = new ShoppingCartItemParameters(skuId, quantity, intOptions); // If product is donation if (skuInfo.SKUProductType == SKUProductTypeEnum.Donation) { // Get donation properties if (price < 0) { cartItemParams.Price = SKUInfoProvider.GetSKUPrice(skuInfo, ShoppingCart, false, false); } else { cartItemParams.Price = price; } cartItemParams.IsPrivate = isPrivate; } // Add product to the shopping cart ShoppingCart.SetShoppingCartItem(cartItemParams); // Log activity if (!ShoppingCartControl.IsInternalOrder) { ShoppingCartControl.TrackActivityProductAddedToShoppingCart(skuInfo, quantity); } // Show empty button btnEmpty.Visible = true; } } } // Invalidate values hidProductID.Value = ""; hidOptions.Value = ""; hidQuantity.Value = ""; hdnPrice.Value = ""; // Update values in table btnUpdate_Click1(btnAddProduct, e); // Hide cart content when empty if (DataHelper.DataSourceIsEmpty(ShoppingCart.ContentTable)) { HideCartContent(); } else { // Inventory should be checked checkInventory = true; } }
private void btnAddProduct_Click(object sender, EventArgs e) { // Do not add item if order is paid if (OrderIsPaid) { return; } // Get strings with productIDs and quantities separated by ';' string productIDs = ValidationHelper.GetString(hidProductID.Value, ""); string quantities = ValidationHelper.GetString(hidQuantity.Value, ""); string options = ValidationHelper.GetString(hidOptions.Value, ""); // Add new products to shopping cart if ((productIDs != "") && (quantities != "")) { int[] arrID = ValidationHelper.GetIntegers(productIDs.TrimEnd(';').Split(';'), 0); int[] arrQuant = ValidationHelper.GetIntegers(quantities.TrimEnd(';').Split(';'), 0); int[] intOptions = ValidationHelper.GetIntegers(options.Split(','), 0); // Check site binding if (!CheckSiteBinding(arrID) || !CheckSiteBinding(intOptions)) { return; } lblError.Text = ""; for (int i = 0; i < arrID.Length; i++) { int skuId = arrID[i]; SKUInfo skuInfo = SKUInfoProvider.GetSKUInfo(skuId); if ((skuInfo != null) && !skuInfo.IsProductOption) { int quantity = arrQuant[i]; ShoppingCartItemParameters cartItemParams = new ShoppingCartItemParameters(skuId, quantity, intOptions); // Add product to the shopping cart ShoppingCartInfoProvider.SetShoppingCartItem(ShoppingCart, cartItemParams); // Log activity if (!ShoppingCartControl.IsInternalOrder) { ShoppingCartControl.TrackActivityProductAddedToShoppingCart(skuInfo, quantity); } // Show empty button btnEmpty.Visible = true; } } } // Invalidate values hidProductID.Value = ""; hidOptions.Value = ""; hidQuantity.Value = ""; ShoppingCart.Evaluate(); // Update values in table btnUpdate_Click(btnAddProduct, e); if (ShoppingCart.ContentTable.Any()) { // Inventory should be checked checkInventory = true; } else { // Hide cart content when empty HideCartContent(); } }
private void btnAddProduct_Click(object sender, EventArgs e) { // Get strings with productIDs and quantities separated by ';' string productIDs = ValidationHelper.GetString(hidProductID.Value, ""); string quantities = ValidationHelper.GetString(hidQuantity.Value, ""); string options = ValidationHelper.GetString(hidOptions.Value, ""); double price = ValidationHelper.GetDouble(hdnPrice.Value, -1); bool isPrivate = ValidationHelper.GetBoolean(hdnIsPrivate.Value, false); // Add new products to shopping cart if ((productIDs != "") && (quantities != "")) { string[] arrID = productIDs.TrimEnd(';').Split(';'); string[] arrQuant = quantities.TrimEnd(';').Split(';'); int[] intOptions = ValidationHelper.GetIntegers(options.Split(','), 0); lblError.Text = ""; for (int i = 0; i < arrID.Length; i++) { int skuId = ValidationHelper.GetInteger(arrID[i], 0); SKUInfo skuInfo = SKUInfoProvider.GetSKUInfo(skuId); if (skuInfo != null) { int quant = ValidationHelper.GetInteger(arrQuant[i], 0); ShoppingCartItemParameters cartItemParams = new ShoppingCartItemParameters(skuId, quant, intOptions); // If product is donation if (skuInfo.SKUProductType == SKUProductTypeEnum.Donation) { // Get donation properties if (price < 0) { cartItemParams.Price = SKUInfoProvider.GetSKUPrice(skuInfo, ShoppingCart, false, false); } else { cartItemParams.Price = price; } cartItemParams.IsPrivate = isPrivate; } // Add product to the shopping cart ShoppingCart.SetShoppingCartItem(cartItemParams); // Log activity string siteName = SiteContext.CurrentSiteName; if (!ShoppingCartControl.IsInternalOrder) { ShoppingCartControl.TrackActivityProductAddedToShoppingCart(skuId, ResHelper.LocalizeString(skuInfo.SKUName), ContactID, siteName, RequestContext.CurrentRelativePath, quant); } // Show empty button btnEmpty.Visible = true; } } } // Invalidate values hidProductID.Value = ""; hidOptions.Value = ""; hidQuantity.Value = ""; hdnPrice.Value = ""; // Update values in table btnUpdate_Click1(btnAddProduct, e); // Hide cart content when empty if (DataHelper.DataSourceIsEmpty(ShoppingCart.ContentTable)) { HideCartContentWhenEmpty(); } else { // Inventory shloud be checked checkInventory = true; } }