/// <summary> /// Setups the control. /// </summary> public void SetupControl() { double value = 0; string stringFormat = ValidationHelper.GetString(GetValue("StringFormat"), ""); // Try to use the stringFormat format, to check, if it's a valid one try { String.Format(stringFormat, value); } catch (Exception ex) { CMS.EventLog.EventLogProvider.LogException("Checkout process", "ERROR", ex, CurrentSite.SiteID, "The StringFormat property of the web part isn't in a correct format: '" + stringFormat + "'"); // Recovery stringFormat = ""; } string type = ValidationHelper.GetString(GetValue("TotalToDisplay"), "TotalPriceOfProducts"); // Display the correct value according to the TotalToDisplay property of the web part switch (type) { case "TotalPriceOfOrder": value = ShoppingCart.TotalPrice; DisplayValue(GetFormattedPriceToDisplay(value, stringFormat)); break; case "TotalPriceOfProducts": value = ShoppingCart.TotalItemsPrice; DisplayValue(GetFormattedPriceToDisplay(value, stringFormat)); break; case "TotalPriceOfProductsWithoutTax": value = ShoppingCart.TotalItemsPrice - ShoppingCart.TotalItemsTax; DisplayValue(GetFormattedPriceToDisplay(value, stringFormat)); break; case "TotalShippingWithoutTax": if (ShoppingCart.ShippingOption != null) { value = ShoppingCart.ApplyExchangeRate(ShippingOptionInfoProvider.CalculateShipping(ShoppingCart)); } DisplayValue(GetFormattedPriceToDisplay(value, stringFormat)); break; case "TotalShipping": if (ShoppingCart.ShippingOption != null) { value = ShoppingCart.TotalShipping; } DisplayValue(GetFormattedPriceToDisplay(value, stringFormat)); break; case "TotalWeight": value = ShoppingCart.TotalItemsWeight; DisplayValue(stringFormat == "" ? ShippingOptionInfoProvider.GetFormattedWeight(value, CurrentSiteName) : String.Format(stringFormat, value)); break; case "TotalProductTax": value = ShoppingCart.TotalTax; DisplayValue(GetFormattedPriceToDisplay(value, stringFormat)); break; case "TotalOrderTax": value = ShoppingCart.TotalTax; if (ShoppingCart.ShippingOption != null) { value += ShoppingCart.ApplyExchangeRate(ShippingOptionInfoProvider.CalculateShippingTax(ShoppingCart)); } DisplayValue(GetFormattedPriceToDisplay(value, stringFormat)); break; case "TotalShippingTax": if (!DataHelper.DataSourceIsEmpty(ShoppingCart.ShippingTaxesTable)) { value = ValidationHelper.GetDoubleSystem(ShoppingCart.ShippingTaxesTable.Rows[0]["TaxSummary"], 0); } DisplayValue(GetFormattedPriceToDisplay(value, stringFormat)); break; case "TotalDiscount": value = ShoppingCart.OrderDiscount + ShoppingCart.ItemsDiscount + ShoppingCart.ShippingDiscount; DisplayValue(GetFormattedPriceToDisplay(value, stringFormat)); break; case "TotalOrderDiscount": value = ShoppingCart.OrderDiscount; DisplayValue(GetFormattedPriceToDisplay(value, stringFormat)); break; case "OrderDiscountSummary": DisplayOrderDiscountSummary(); break; } }