public string GetAttributeDescription(ShoppingCartItem shoppingCartItem) { string result = ProductAttributeHelper.FormatAttributes(shoppingCartItem.ProductVariant, shoppingCartItem.AttributesXml, customer, "<br />"); if (!String.IsNullOrEmpty(result)) result = "<br />" + result; return result; }
public string GetProductVariantName(ShoppingCartItem shoppingCartItem) { ProductVariant productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) return productVariant.FullProductName; return "Not available"; }
public string GetShoppingCartItemSubTotalString(ShoppingCartItem shoppingCartItem) { Customer customer = shoppingCartItem.CustomerSession.Customer; StringBuilder sb = new StringBuilder(); decimal taxRate = decimal.Zero; decimal shoppingCartItemSubTotalWithDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, customer, true), customer, out taxRate); decimal shoppingCartItemSubTotalWithDiscount = CurrencyManager.ConvertCurrency(shoppingCartItemSubTotalWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string subTotalString = PriceHelper.FormatPrice(shoppingCartItemSubTotalWithDiscount); sb.Append(subTotalString); decimal shoppingCartItemDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetDiscountAmount(shoppingCartItem, customer), customer, out taxRate); if (shoppingCartItemDiscountBase > decimal.Zero) { decimal shoppingCartItemDiscount = CurrencyManager.ConvertCurrency(shoppingCartItemDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string discountString = PriceHelper.FormatPrice(shoppingCartItemDiscount); sb.Append("<br />"); //sb.Append(GetLocaleResourceString("ShoppingCart.ItemYouSave")); sb.Append("Saved:"); sb.Append(" "); sb.Append(discountString); } return sb.ToString(); }
public string GetProductVariantUrl(ShoppingCartItem shoppingCartItem) { string result = string.Empty; if (shoppingCartItem == null) return result; ProductVariant productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) result = "ProductVariantDetails.aspx?ProductVariantID=" + productVariant.ProductVariantId.ToString(); else result = "Not available. Product variant ID=" + shoppingCartItem.ProductVariantId.ToString(); return result; }
/// <summary> /// Gets discount amount /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <param name="customer">The customer</param> /// <returns>Discount amount</returns> public static decimal GetDiscountAmount(ShoppingCartItem shoppingCartItem, Customer customer) { Discount appliedDiscount = null; return GetDiscountAmount(shoppingCartItem, customer, out appliedDiscount); }
public string GetShoppingCartItemUnitPriceString(ShoppingCartItem shoppingCartItem) { StringBuilder sb = new StringBuilder(); decimal taxRate = decimal.Zero; decimal shoppingCartUnitPriceWithDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetUnitPrice(shoppingCartItem, customer, true), customer, out taxRate); decimal shoppingCartUnitPriceWithDiscount = CurrencyManager.ConvertCurrency(shoppingCartUnitPriceWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string unitPriceString = PriceHelper.FormatPrice(shoppingCartUnitPriceWithDiscount); sb.Append(unitPriceString); return sb.ToString(); }
public string GetShoppingCartItemUnitPriceString(ShoppingCartItem shoppingCartItem) { var sb = new StringBuilder(); if (shoppingCartItem.ProductVariant.CallForPrice) { sb.Append("<span class=\"productPrice\">"); sb.Append(GetLocaleResourceString("Products.CallForPrice")); sb.Append("</span>"); } else { decimal taxRate = decimal.Zero; decimal shoppingCartUnitPriceWithDiscountBase = this.TaxService.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetUnitPrice(shoppingCartItem, true), out taxRate); decimal shoppingCartUnitPriceWithDiscount = this.CurrencyService.ConvertCurrency(shoppingCartUnitPriceWithDiscountBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string unitPriceString = PriceHelper.FormatPrice(shoppingCartUnitPriceWithDiscount); sb.Append("<span class=\"productPrice\">"); sb.Append(unitPriceString); sb.Append("</span>"); } return sb.ToString(); }
public string GetRecurringDescription(ShoppingCartItem shoppingCartItem) { string result = string.Empty; if (shoppingCartItem.ProductVariant.IsRecurring) { result = string.Format(GetLocaleResourceString("Wishlist.RecurringPeriod"), shoppingCartItem.ProductVariant.CycleLength, ((RecurringProductCyclePeriodEnum)shoppingCartItem.ProductVariant.CyclePeriod).ToString()); if (!String.IsNullOrEmpty(result)) result = "<br />" + result; } return result; }
/// <summary> /// Gets discount amount /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <returns>Discount amount</returns> public static decimal GetDiscountAmount(ShoppingCartItem shoppingCartItem) { Customer customer = NopContext.Current.User; return GetDiscountAmount(shoppingCartItem, customer); }
/// <summary> /// Gets the shopping cart unit price (one item) /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <param name="customer">The customer</param> /// <param name="includeDiscounts">A value indicating whether include discounts or not for price computation</param> /// <returns>Shopping cart unit price (one item)</returns> public static decimal GetUnitPrice(ShoppingCartItem shoppingCartItem, Customer customer, bool includeDiscounts) { decimal finalPrice = decimal.Zero; ProductVariant productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) { decimal attributesTotalPrice = decimal.Zero; ProductVariantAttributeValueCollection pvaValues = ProductAttributeHelper.ParseProductVariantAttributeValues(shoppingCartItem.AttributesXML); foreach (ProductVariantAttributeValue pvaValue in pvaValues) { attributesTotalPrice += pvaValue.PriceAdjustment; } finalPrice = GetFinalPrice(productVariant, customer, attributesTotalPrice, includeDiscounts); if (productVariant.TierPrices.Count > 0) { decimal tierPrice = GetTierPrice(productVariant, shoppingCartItem.Quantity); finalPrice = Math.Min(finalPrice, tierPrice); } } finalPrice = Math.Round(finalPrice, 2); return finalPrice; }
/// <summary> /// Gets the shopping cart unit price (one item) /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <param name="includeDiscounts">A value indicating whether include discounts or not for price computation</param> /// <returns>Shopping cart unit price (one item)</returns> public static decimal GetUnitPrice(ShoppingCartItem shoppingCartItem, bool includeDiscounts) { Customer customer = NopContext.Current.User; return GetUnitPrice(shoppingCartItem, customer, includeDiscounts); }
/// <summary> /// Gets the shopping cart item sub total /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <param name="customer">The customer</param> /// <param name="includeDiscounts">A value indicating whether include discounts or not for price computation</param> /// <returns>Shopping cart item sub total</returns> public static decimal GetSubTotal(ShoppingCartItem shoppingCartItem, Customer customer, bool includeDiscounts) { return GetUnitPrice(shoppingCartItem, customer, includeDiscounts) * shoppingCartItem.Quantity; }
/// <summary> /// Gets the shopping cart unit price (one item) /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <param name="customer">The customer</param> /// <param name="includeDiscounts">A value indicating whether include discounts or not for price computation</param> /// <returns>Shopping cart unit price (one item)</returns> public static decimal GetUnitPrice(ShoppingCartItem shoppingCartItem, Customer customer, bool includeDiscounts) { decimal finalPrice = decimal.Zero; var productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) { decimal attributesTotalPrice = decimal.Zero; var pvaValues = ProductAttributeHelper.ParseProductVariantAttributeValues(shoppingCartItem.AttributesXml); foreach (var pvaValue in pvaValues) { attributesTotalPrice += pvaValue.PriceAdjustment; } if (productVariant.CustomerEntersPrice) { finalPrice = shoppingCartItem.CustomerEnteredPrice; } else { finalPrice = GetFinalPrice(productVariant, customer, attributesTotalPrice, includeDiscounts, shoppingCartItem.Quantity); } } finalPrice = Math.Round(finalPrice, 2); return finalPrice; }
/// <summary> /// Gets the shopping cart item sub total /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <param name="includeDiscounts">A value indicating whether include discounts or not for price computation</param> /// <returns>Shopping cart item sub total</returns> public static decimal GetSubTotal(ShoppingCartItem shoppingCartItem, bool includeDiscounts) { var customer = NopContext.Current.User; return GetSubTotal(shoppingCartItem, customer, includeDiscounts); }
public string GetProductUrl(ShoppingCartItem shoppingCartItem) { var productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) return SEOHelper.GetProductUrl(productVariant.ProductId); return string.Empty; }
public string GetProductVariantImageUrl(ShoppingCartItem shoppingCartItem) { string pictureUrl = String.Empty; var productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) { var productVariantPicture = productVariant.Picture; pictureUrl = this.PictureService.GetPictureUrl(productVariantPicture, this.SettingManager.GetSettingValueInteger("Media.ShoppingCart.ThumbnailImageSize", 80), false); if (String.IsNullOrEmpty(pictureUrl)) { var product = productVariant.Product; var picture = product.DefaultPicture; if (picture != null) { pictureUrl = this.PictureService.GetPictureUrl(picture, this.SettingManager.GetSettingValueInteger("Media.ShoppingCart.ThumbnailImageSize", 80)); } else { pictureUrl = this.PictureService.GetDefaultPictureUrl(this.SettingManager.GetSettingValueInteger("Media.ShoppingCart.ThumbnailImageSize", 80)); } } } return pictureUrl; }
/// <summary> /// Gets discount amount /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <param name="customer">The customer</param> /// <returns>Discount amount</returns> public static decimal GetDiscountAmount(ShoppingCartItem shoppingCartItem, Customer customer) { decimal discountAmount = decimal.Zero; ProductVariant productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) { decimal attributesTotalPrice = decimal.Zero; ProductVariantAttributeValueCollection pvaValues = ProductAttributeHelper.ParseProductVariantAttributeValues(shoppingCartItem.AttributesXML); foreach (ProductVariantAttributeValue pvaValue in pvaValues) { attributesTotalPrice += pvaValue.PriceAdjustment; } decimal productVariantDiscountAmount = GetDiscountAmount(productVariant, customer, attributesTotalPrice); discountAmount = productVariantDiscountAmount * shoppingCartItem.Quantity; } discountAmount = Math.Round(discountAmount, 2); return discountAmount; }
public string GetShoppingCartItemSubTotalString(ShoppingCartItem shoppingCartItem) { var sb = new StringBuilder(); if (shoppingCartItem.ProductVariant.CallForPrice) { sb.Append("<span class=\"productPrice\">"); sb.Append(GetLocaleResourceString("Products.CallForPrice")); sb.Append("</span>"); } else { //sub total decimal taxRate = decimal.Zero; decimal shoppingCartItemSubTotalWithDiscountBase = this.TaxService.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, true), out taxRate); decimal shoppingCartItemSubTotalWithDiscount = this.CurrencyService.ConvertCurrency(shoppingCartItemSubTotalWithDiscountBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string subTotalString = PriceHelper.FormatPrice(shoppingCartItemSubTotalWithDiscount); sb.Append("<span class=\"productPrice\">"); sb.Append(subTotalString); sb.Append("</span>"); //display an applied discount amount decimal shoppingCartItemSubTotalWithoutDiscountBase = this.TaxService.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, false), out taxRate); decimal shoppingCartItemDiscountBase = shoppingCartItemSubTotalWithoutDiscountBase - shoppingCartItemSubTotalWithDiscountBase; if (shoppingCartItemDiscountBase > decimal.Zero) { decimal shoppingCartItemDiscount = this.CurrencyService.ConvertCurrency(shoppingCartItemDiscountBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string discountString = PriceHelper.FormatPrice(shoppingCartItemDiscount); sb.Append("<br />"); sb.Append(GetLocaleResourceString("Wishlist.ItemYouSave")); sb.Append(" "); sb.Append(discountString); } } return sb.ToString(); }
/// <summary> /// Inserts a shopping cart item /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> internal void InsertShoppingCartItem(ShoppingCartItem shoppingCartItem) { if (shoppingCartItem == null) throw new ArgumentNullException("shoppingCartItem"); shoppingCartItem.AttributesXml = CommonHelper.EnsureNotNull(shoppingCartItem.AttributesXml); _context.ShoppingCartItems.AddObject(shoppingCartItem); _context.SaveChanges(); if (shoppingCartItem != null) { if (shoppingCartItem.ShoppingCartType == ShoppingCartTypeEnum.ShoppingCart) { IoC.Resolve<ICustomerActivityService>().InsertActivity( "AddToShoppingCart", IoC.Resolve<ILocalizationManager>().GetLocaleResourceString("ActivityLog.AddToShoppingCart"), shoppingCartItem.ProductVariant.FullProductName); } } }
/// <summary> /// Add a product variant to shopping cart /// </summary> /// <param name="ShoppingCartType">Shopping cart type</param> /// <param name="ProductVariantID">Product variant identifier</param> /// <param name="SelectedAttributes">Selected attributes</param> /// <param name="Quantity">Quantity</param> /// <returns>Warnings</returns> public static List <string> AddToCart(ShoppingCartTypeEnum ShoppingCartType, int ProductVariantID, string SelectedAttributes, int Quantity) { List <string> warnings = new List <string>(); if (ShoppingCartType == ShoppingCartTypeEnum.Wishlist && !SettingManager.GetSettingValueBoolean("Common.EnableWishlist")) { return(warnings); } if (NopContext.Current.Session == null) { NopContext.Current.Session = NopContext.Current.GetSession(true); } Guid CustomerSessionGUID = NopContext.Current.Session.CustomerSessionGUID; CustomerManager.ResetCheckoutData(NopContext.Current.Session.CustomerID, false); ShoppingCart Cart = GetShoppingCartByCustomerSessionGUID(ShoppingCartType, CustomerSessionGUID); ShoppingCartItem shoppingCartItem = null; foreach (ShoppingCartItem _shoppingCartItem in Cart) { if (_shoppingCartItem.ProductVariantID == ProductVariantID) { if (ProductAttributeHelper.ParseProductVariantAttributeIDs(_shoppingCartItem.AttributesXML).Count == ProductAttributeHelper.ParseProductVariantAttributeIDs(SelectedAttributes).Count) { bool attributeEquals = true; ProductVariantAttributeCollection pva1Collection = ProductAttributeHelper.ParseProductVariantAttributes(SelectedAttributes); ProductVariantAttributeCollection pva2Collection = ProductAttributeHelper.ParseProductVariantAttributes(_shoppingCartItem.AttributesXML); foreach (ProductVariantAttribute pva1 in pva1Collection) { foreach (ProductVariantAttribute pva2 in pva2Collection) { if (pva1.ProductVariantAttributeID == pva2.ProductVariantAttributeID) { List <string> pvaValues1Str = ProductAttributeHelper.ParseValues(SelectedAttributes, pva1.ProductVariantAttributeID); List <string> pvaValues2Str = ProductAttributeHelper.ParseValues(_shoppingCartItem.AttributesXML, pva2.ProductVariantAttributeID); if (pvaValues1Str.Count == pvaValues2Str.Count) { foreach (string str1 in pvaValues1Str) { bool hasAttribute = false; foreach (string str2 in pvaValues2Str) { if (str1.Trim().ToLower() == str2.Trim().ToLower()) { hasAttribute = true; break; } } if (!hasAttribute) { attributeEquals = false; break; } } } else { attributeEquals = false; break; } } } } if (attributeEquals) { shoppingCartItem = _shoppingCartItem; } } } } DateTime now = DateTime.Now; if (shoppingCartItem != null) { int newQuantity = shoppingCartItem.Quantity + Quantity; warnings.AddRange(GetShoppingCartItemWarnings(ShoppingCartType, ProductVariantID, SelectedAttributes, newQuantity)); if (warnings.Count == 0) { UpdateShoppingCartItem(shoppingCartItem.ShoppingCartItemID, ShoppingCartType, CustomerSessionGUID, ProductVariantID, SelectedAttributes, newQuantity, shoppingCartItem.CreatedOn, now); } } else { warnings.AddRange(GetShoppingCartItemWarnings(ShoppingCartType, ProductVariantID, SelectedAttributes, Quantity)); if (warnings.Count == 0) { InsertShoppingCartItem(ShoppingCartType, CustomerSessionGUID, ProductVariantID, SelectedAttributes, Quantity, now, now); } } return(warnings); }
/// <summary> /// Updates the shopping cart item /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> internal void UpdateShoppingCartItem(ShoppingCartItem shoppingCartItem) { if (shoppingCartItem == null) throw new ArgumentNullException("shoppingCartItem"); shoppingCartItem.AttributesXml = CommonHelper.EnsureNotNull(shoppingCartItem.AttributesXml); if (!_context.IsAttached(shoppingCartItem)) _context.ShoppingCartItems.Attach(shoppingCartItem); _context.SaveChanges(); }
/// <summary> /// Add a product variant to shopping cart /// </summary> /// <param name="shoppingCartType">Shopping cart type</param> /// <param name="productVariantId">Product variant identifier</param> /// <param name="selectedAttributes">Selected attributes</param> /// <param name="customerEnteredPrice">The price enter by a customer</param> /// <param name="quantity">Quantity</param> /// <returns>Warnings</returns> public List<string> AddToCart(ShoppingCartTypeEnum shoppingCartType, int productVariantId, string selectedAttributes, decimal customerEnteredPrice, int quantity) { var warnings = new List<string>(); if (shoppingCartType == ShoppingCartTypeEnum.Wishlist && !IoC.Resolve<ISettingManager>().GetSettingValueBoolean("Common.EnableWishlist")) return warnings; if (NopContext.Current.Session == null) NopContext.Current.Session = NopContext.Current.GetSession(true); var customerSessionGuid = NopContext.Current.Session.CustomerSessionGuid; IoC.Resolve<ICustomerService>().ResetCheckoutData(NopContext.Current.Session.CustomerId, false); var cart = GetShoppingCartByCustomerSessionGuid(shoppingCartType, customerSessionGuid); ShoppingCartItem shoppingCartItem = null; foreach (var _shoppingCartItem in cart) { if (_shoppingCartItem.ProductVariantId == productVariantId) { //attributes bool attributesEqual = ProductAttributeHelper.AreProductAttributesEqual(_shoppingCartItem.AttributesXml, selectedAttributes); //gift cards bool giftCardInfoSame = true; if (_shoppingCartItem.ProductVariant.IsGiftCard) { string giftCardRecipientName1 = string.Empty; string giftCardRecipientEmail1 = string.Empty; string giftCardSenderName1 = string.Empty; string giftCardSenderEmail1 = string.Empty; string giftCardMessage1 = string.Empty; ProductAttributeHelper.GetGiftCardAttribute(selectedAttributes, out giftCardRecipientName1, out giftCardRecipientEmail1, out giftCardSenderName1, out giftCardSenderEmail1, out giftCardMessage1); string giftCardRecipientName2 = string.Empty; string giftCardRecipientEmail2 = string.Empty; string giftCardSenderName2 = string.Empty; string giftCardSenderEmail2 = string.Empty; string giftCardMessage2 = string.Empty; ProductAttributeHelper.GetGiftCardAttribute(_shoppingCartItem.AttributesXml, out giftCardRecipientName2, out giftCardRecipientEmail2, out giftCardSenderName2, out giftCardSenderEmail2, out giftCardMessage2); if (giftCardRecipientName1.ToLowerInvariant() != giftCardRecipientName2.ToLowerInvariant() || giftCardSenderName1.ToLowerInvariant() != giftCardSenderName2.ToLowerInvariant()) giftCardInfoSame = false; } //price is the same (for products which requires customers to enter a price) bool customerEnteredPricesEqual = true; if (_shoppingCartItem.ProductVariant.CustomerEntersPrice) { customerEnteredPricesEqual = Math.Round(_shoppingCartItem.CustomerEnteredPrice, 2) == Math.Round(customerEnteredPrice, 2); } if (attributesEqual && giftCardInfoSame && customerEnteredPricesEqual) shoppingCartItem = _shoppingCartItem; } } DateTime now = DateTime.UtcNow; if (shoppingCartItem != null) { int newQuantity = shoppingCartItem.Quantity + quantity; warnings.AddRange(GetShoppingCartItemWarnings(shoppingCartType, productVariantId, selectedAttributes, customerEnteredPrice, newQuantity)); if (warnings.Count == 0) { shoppingCartItem.ShoppingCartTypeId = (int)shoppingCartType; shoppingCartItem.CustomerSessionGuid = customerSessionGuid; shoppingCartItem.ProductVariantId = productVariantId; shoppingCartItem.AttributesXml = selectedAttributes; shoppingCartItem.Quantity = newQuantity; shoppingCartItem.UpdatedOn = now; UpdateShoppingCartItem(shoppingCartItem); } } else { warnings.AddRange(GetShoppingCartItemWarnings(shoppingCartType, productVariantId, selectedAttributes, customerEnteredPrice, quantity)); if (warnings.Count == 0) { //maximum items validation if (shoppingCartType == ShoppingCartTypeEnum.ShoppingCart) { if (cart.Count >= IoC.Resolve<ISettingManager>().GetSettingValueInteger("Common.MaximumShoppingCartItems", 1000)) { return warnings; } } else if (shoppingCartType == ShoppingCartTypeEnum.Wishlist) { if (cart.Count >= IoC.Resolve<ISettingManager>().GetSettingValueInteger("Common.MaximumWishlistItems", 1000)) { return warnings; } } //insert item shoppingCartItem = new ShoppingCartItem() { ShoppingCartTypeId = (int)shoppingCartType, CustomerSessionGuid = customerSessionGuid, ProductVariantId = productVariantId, AttributesXml = selectedAttributes, CustomerEnteredPrice = customerEnteredPrice, Quantity = quantity, CreatedOn = now, UpdatedOn = now }; InsertShoppingCartItem(shoppingCartItem); } } return warnings; }
/// <summary> /// Gets discount amount /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <param name="customer">The customer</param> /// <param name="appliedDiscount">Applied discount</param> /// <returns>Discount amount</returns> public static decimal GetDiscountAmount(ShoppingCartItem shoppingCartItem, Customer customer, out Discount appliedDiscount) { appliedDiscount = null; decimal discountAmount = decimal.Zero; var productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) { decimal attributesTotalPrice = decimal.Zero; var pvaValues = ProductAttributeHelper.ParseProductVariantAttributeValues(shoppingCartItem.AttributesXml); foreach (var pvaValue in pvaValues) { attributesTotalPrice += pvaValue.PriceAdjustment; } decimal productVariantDiscountAmount = GetDiscountAmount(productVariant, customer, attributesTotalPrice, shoppingCartItem.Quantity, out appliedDiscount); discountAmount = productVariantDiscountAmount * shoppingCartItem.Quantity; } discountAmount = Math.Round(discountAmount, 2); return discountAmount; }