protected void Page_PreRender(object sender, EventArgs e) { // REGISTER WARNING SCRIPTS IF THE PRODUCT HAS CUSTOMIZED VARIANTS string warnScript; int productId = AbleCommerce.Code.PageHelper.GetProductId(); Product product = ProductDataSource.Load(productId); if (product != null) { bool hasDigitalGoods = ProductVariantManager.HasDigitalGoodData(productId); if (hasDigitalGoods || product.KitStatus == KitStatus.Member) { String delMesssage = String.Empty; if (hasDigitalGoods) { delMesssage += "WARNING: If there are digital goods linked to variants with this choice, deleting the choice will unlink these digital goods.\\n\\n"; } if (product.KitStatus == KitStatus.Member) { delMesssage += "WARNING: This product is part of one or more kit products. Deleting this choice will remove any variants with this choice from those kit products.\\n\\n"; } warnScript = "function confirmDel(){return confirm('" + delMesssage + "Are you sure you want to delete this choice?');}"; } else { warnScript = "function confirmDel(){return confirm('Are you sure you want to delete this choice?');}"; } this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "checkVariant", warnScript, true); } }
protected void Page_PreRender(object sender, EventArgs e) { string warnScript; bool hasVariantData = ProductVariantManager.HasVariantData(_ProductId); bool hasDigitalGoods = ProductVariantManager.HasDigitalGoodData(_ProductId); if (hasVariantData || hasDigitalGoods || _Product.KitStatus == KitStatus.Member) { String delMesssage = String.Empty; String addMessage = String.Empty; if (hasVariantData) { delMesssage += "WARNING: If you have made changes to the variant grid, such as adjusting the variant price or in-stock levels, deleting an option will reset this data.\\n\\n"; addMessage += "WARNING: If you have made changes to the variant grid, such as adjusting the variant price or in-stock levels, adding an option will reset this data. \\n\\n"; } if (hasDigitalGoods) { delMesssage += "WARNING: There are digital goods attached to one or more variants, deleting this option will remove all associated digital goods.\\n\\n"; addMessage += "WARNING: There are digital goods attached to one or more existing variants, adding an option will remove all associated digital goods.\\n\\n"; } if (_Product.KitStatus == KitStatus.Member) { addMessage += "WARNING: This product is part of one or more kit products, adding an option will remove this product from those kit products.\\n\\n"; delMesssage += "WARNING: This product is part of one or more kit products, deleting an option will remove this product from those kit products.\\n\\n"; } warnScript = "function confirmAdd(){return confirm('" + addMessage + " Are you sure you want to continue?');}\r\n"; warnScript += "function confirmDel(){return confirm('" + delMesssage + "Are you sure you want to delete this option?');}"; } else { warnScript = "function confirmAdd(){return true;}"; warnScript += "function confirmDel(){return confirm('Are you sure you want to delete this option?');}"; } ScriptManager.RegisterStartupScript(OptionsPanel, OptionsPanel.GetType(), "checkVariant", warnScript, true); }