/// <summary> /// Compute Sub total needed to avail free shipping. FreeShippingThreshold and ShippingMethodCodeIfFreeShippingIsOn appconfig MUST be setup /// properly for this feature to work. /// </summary> private void ShowFreeshippingInfo() { decimal threshHold = AppLogic.AppConfigUSDecimal("FreeShippingThreshold"); string currencyCode = _cart.ThisCustomer.CurrencyCode; decimal subTotal = _cart.GetCartSubTotalExcludeOversized(); string shippingMethods = AppLogic.AppConfig("ShippingMethodCodeIfFreeShippingIsOn"); string total; if (threshHold > decimal.Zero && threshHold > subTotal) { pnlGetFreeShippingMsg.Visible = true; total = InterpriseHelper.FormatCurrencyForCustomer(threshHold, currencyCode); GetFreeShippingMsg.Text = string.Format(AppLogic.GetString("checkoutshipping.aspx.2", SkinID, ThisCustomer.LocaleSetting), total, shippingMethods); } }
void OrderOptionsList_ItemDataBound(object sender, RepeaterItemEventArgs e) { XmlNode orderOptionNode = e.Item.DataItem as XmlNode; int counter = 0; if (orderOptionNode != null && int.TryParse(orderOptionNode["Counter"].InnerText, out counter)) { string itemCode = orderOptionNode["ItemCode"].InnerText; string itemName = orderOptionNode["ItemName"].InnerText; string itemDescription = orderOptionNode["ItemDescription"].InnerText; string popupTitle = string.Empty; Label lblDisplayName = e.Item.FindControl("OrderOptionName") as Label; if (!CommonLogic.IsStringNullOrEmpty(itemDescription)) { lblDisplayName.Text = Security.HtmlEncode(itemDescription); popupTitle = CommonLogic.Left(Security.UrlEncode(SE.MungeName(itemDescription)), 90); } else { lblDisplayName.Text = Security.HtmlEncode(itemName); popupTitle = CommonLogic.Left(Security.UrlEncode(SE.MungeName(itemName)), 90); } if (AppLogic.AppConfigBool("ShowPicsInCart")) { String ImgUrl = InterpriseHelper.LookUpImageByItemCode(itemCode, "icon", SkinID, ThisCustomer.LocaleSetting); if (!string.IsNullOrEmpty(ImgUrl) && ImgUrl.IndexOf("nopicture") == -1) { Image imgControl = (Image)e.Item.FindControl("OptionImage"); imgControl.ImageUrl = ImgUrl; imgControl.Visible = true; } } var helpCircle = (Image)e.Item.FindControl("helpcircle_gif"); helpCircle.ImageUrl = AppLogic.LocateImageURL(SkinImagePath + "helpcircle.gif"); helpCircle.Attributes.Add("onclick", "popuporderoptionwh('Order Option " + popupTitle + "', " + counter.ToString() + ",650,550,'yes');"); // 2 Control choices for drop down list var cboUnitMeasureCode = e.Item.FindControl("cboUnitMeasureCode") as DropDownList; var lblUnitMeasureCode = e.Item.FindControl("lblUnitMeasureCode") as Label; var availableUnitMeasures = ProductDA.GetProductUnitMeasureAvailability(ThisCustomer.CustomerCode, itemCode, AppLogic.AppConfigBool("ShowInventoryFromAllWarehouses"), ThisCustomer.IsNotRegistered); if (availableUnitMeasures.Count() > 1) { // render as drop down list lblUnitMeasureCode.Visible = false; foreach (string unitMeasureCode in availableUnitMeasures) { cboUnitMeasureCode.Items.Add(new ListItem(HttpUtility.HtmlEncode(unitMeasureCode), HttpUtility.HtmlEncode(unitMeasureCode))); } } else { // The only unit measure the item is configured for is the default // which we are guaranteed to be in the first index.. cboUnitMeasureCode.Visible = false; lblUnitMeasureCode.Text = availableUnitMeasures.First().ToHtmlEncode(); } bool withVat = AppLogic.AppConfigBool("VAT.Enabled") && ThisCustomer.VATSettingReconciled == VatDefaultSetting.Inclusive; var um = UnitMeasureInfo.ForItem(itemCode, UnitMeasureInfo.ITEM_DEFAULT); decimal promotionalPrice = Decimal.Zero; decimal price = InterpriseHelper.GetSalesPriceAndTax(ThisCustomer.CustomerCode, itemCode, ThisCustomer.CurrencyCode, Decimal.One, um.Code, withVat, ref promotionalPrice); if (promotionalPrice != Decimal.Zero) { price = promotionalPrice; } string vatDisplay = String.Empty; if (AppLogic.AppConfigBool("VAT.Enabled")) { vatDisplay = (ThisCustomer.VATSettingReconciled == VatDefaultSetting.Inclusive)? " <span class=\"VATLabel\">" + AppLogic.GetString("showproduct.aspx.38", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + "</span>\n": " <span class=\"VATLabel\">" + AppLogic.GetString("showproduct.aspx.37", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + "</span>\n"; } var lblPrice = e.Item.FindControl("OrderOptionPrice") as Label; lblPrice.Text = InterpriseHelper.FormatCurrencyForCustomer(price, ThisCustomer.CurrencyCode) + vatDisplay; var hfCounter = e.Item.FindControl("hfItemCounter") as HiddenField; hfCounter.Value = counter.ToString(); var cbk = (DataCheckBox)e.Item.FindControl("OrderOptions"); cbk.Checked = false; bool shouldBeAbleToEnterNotes = orderOptionNode["CheckOutOptionAddMessage"].InnerText.TryParseBool().Value; var lblNotes = e.Item.FindControl("lblNotes") as Label; var txtNotes = e.Item.FindControl("txtOrderOptionNotes") as TextBox; lblNotes.Visible = txtNotes.Visible = shouldBeAbleToEnterNotes; txtNotes.Attributes.Add("onkeyup", "return imposeMaxLength(this, 1000);"); } }
public void InitializePageContent() { int AgeCartDays = AppLogic.AppConfigUSInt("AgeCartDays"); if (AgeCartDays == 0) { AgeCartDays = 7; } ShoppingCart.Age(ThisCustomer.CustomerID, AgeCartDays, CartTypeEnum.ShoppingCart); shoppingcartaspx8.Text = AppLogic.GetString("shoppingcart.aspx.6", SkinID, ThisCustomer.LocaleSetting); shoppingcartaspx10.Text = AppLogic.GetString("shoppingcart.aspx.8", SkinID, ThisCustomer.LocaleSetting); shoppingcartaspx11.Text = AppLogic.GetString("shoppingcart.aspx.9", SkinID, ThisCustomer.LocaleSetting); shoppingcartaspx9.Text = AppLogic.GetString("shoppingcart.aspx.7", SkinID, ThisCustomer.LocaleSetting); shoppingcartcs27.Text = AppLogic.GetString("shoppingcart.cs.5", SkinID, ThisCustomer.LocaleSetting); shoppingcartcs28.Text = AppLogic.GetString("shoppingcart.cs.6", SkinID, ThisCustomer.LocaleSetting); shoppingcartcs29.Text = AppLogic.GetString("shoppingcart.cs.7", SkinID, ThisCustomer.LocaleSetting); shoppingcartcs31.Text = AppLogic.GetString("shoppingcart.cs.9", SkinID, ThisCustomer.LocaleSetting); //removed for mobile design //btnUpdateCart1.Text = AppLogic.GetString("shoppingcart.cs.33", SkinID, ThisCustomer.LocaleSetting); //btnUpdateCart2.Text = AppLogic.GetString("shoppingcart.cs.33", SkinID, ThisCustomer.LocaleSetting); //btnUpdateCart3.Text = AppLogic.GetString("shoppingcart.cs.33", SkinID, ThisCustomer.LocaleSetting); //btnUpdateCart4.Text = AppLogic.GetString("shoppingcart.cs.33", SkinID, ThisCustomer.LocaleSetting); lblOrderNotes.Text = AppLogic.GetString("shoppingcart.cs.13", SkinID, ThisCustomer.LocaleSetting); btnContinueShoppingTop.Text = AppLogic.GetString("shoppingcart.cs.12", SkinID, ThisCustomer.LocaleSetting); //btnContinueShoppingBottom.Text = AppLogic.GetString("shoppingcart.cs.12", SkinID, ThisCustomer.LocaleSetting); btnCheckOutNowTop.Text = AppLogic.GetString("shoppingcart.cs.34", SkinID, ThisCustomer.LocaleSetting); btnCheckOutNowBottom.Text = AppLogic.GetString("shoppingcart.cs.34", SkinID, ThisCustomer.LocaleSetting); OrderNotes.Attributes.Add("onkeyup", "return imposeMaxLength(this, 255);"); RedirectToShoppingCart = false; if (cart == null) { cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true); if (!Page.IsPostBack) { if (cart.HasRegistryItems()) { cart.RemoveRegistryItems(); ErrorMsgLabel.Text = AppLogic.GetString("mobile.shoppingcart.error.1", SkinID, ThisCustomer.LocaleSetting).ToHtmlDecode(); ErrorMsgLabel.Visible = true; cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true); } string couponCode = string.Empty; string couponErrorMessage = string.Empty; if (cart.HasCoupon(ref couponCode) && cart.IsCouponValid(ThisCustomer, couponCode, ref couponErrorMessage)) { CouponCode.Text = couponCode; } else { if (!couponErrorMessage.IsNullOrEmptyTrimmed()) { ErrorMsgLabel.Text = couponErrorMessage.ToHtmlDecode(); } cart.ClearCoupon(); } //check customer IsCreditHold if (ThisCustomer.IsCreditOnHold && cart != null) { ErrorMsgLabel.Text = AppLogic.GetString("shoppingcart.aspx.18", ThisCustomer.SkinID, ThisCustomer.LocaleSetting); cart.ClearCoupon(); RedirectToShoppingCart = true; } else { if (AppLogic.AppConfigBool("ShowShipDateInCart") && AppLogic.AppConfigBool("ShowStockHints") && cart != null) { cart.BuildSalesOrderDetails(); } } } else { if (string.IsNullOrEmpty(CouponCode.Text)) { cart.ClearCoupon(); } } } if (cart.IsEmpty()) { btnUpdateCart1.Visible = false; AlternativeCheckouts.Visible = false; } else { cart.BuildSalesOrderDetails(); } string BACKURL = AppLogic.GetCartContinueShoppingURL(SkinID, ThisCustomer.LocaleSetting); var html = new StringBuilder(""); html.Append("<script type=\"text/javascript\" >\n"); html.Append("function Cart_Validator(theForm)\n"); html.Append("{\n"); string cartJS = CommonLogic.ReadFile("js/shoppingcart.js", true); foreach (var c in cart.CartItems) { string itemJS = string.Empty; itemJS = cartJS.Replace("%MAX_QUANTITY_INPUT%", AppLogic.MAX_QUANTITY_INPUT_NoDec).Replace("%ALLOWED_QUANTITY_INPUT%", AppLogic.GetQuantityRegularExpression(c.ItemType, true)); itemJS = itemJS.Replace("%DECIMAL_SEPARATOR%", Localization.GetNumberDecimalSeparatorLocaleString(ThisCustomer.LocaleSetting)).Replace("%LOCALE_ZERO%", Localization.GetNumberZeroLocaleString(ThisCustomer.LocaleSetting)); html.Append(itemJS.Replace("%SKU%", c.m_ShoppingCartRecordID.ToString())); } html.Append("return(true);\n"); html.Append("}\n"); html.Append("function imposeMaxLength(theControl, maxLength)\n"); html.Append("{\n"); html.Append("theControl.value = theControl.value.substring(0, maxLength);\n"); html.Append("}\n"); html.Append("</script>\n"); string x = ThisCustomer.LocaleSetting; ValidationScript.Text = html.ToString(); //JSPopupRoutines.Text = AppLogic.GetJSPopupRoutines(); string XmlPackageName = AppLogic.AppConfig("XmlPackage.ShoppingCartPageHeader"); if (XmlPackageName.Length != 0) { XmlPackage_ShoppingCartPageHeader.Text = AppLogic.RunXmlPackage(XmlPackageName, base.GetParser, ThisCustomer, SkinID, String.Empty, null, true, true); } string XRI = AppLogic.LocateImageURL(SkinImagePath + "redarrow.gif"); redarrow1.ImageUrl = XRI; redarrow2.ImageUrl = XRI; redarrow3.ImageUrl = XRI; redarrow4.ImageUrl = XRI; ShippingInformation.Visible = (!AppLogic.AppConfigBool("SkipShippingOnCheckout")); AddresBookLlink.Visible = (ThisCustomer.IsRegistered); btnCheckOutNowTop.Visible = (!cart.IsEmpty()); if (!IsPostBack) { if (CommonLogic.QueryStringCanBeDangerousContent("ErrorMsg").Length != 0 || ErrorMsgLabel.Text.Length > 0) { if (CommonLogic.QueryStringCanBeDangerousContent("ErrorMsg").IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1) { throw new ArgumentException("SECURITY EXCEPTION"); } pnlErrorMsg.Visible = true; ErrorMsgLabel.Text += Server.HtmlEncode(CommonLogic.QueryStringCanBeDangerousContent("ErrorMsg")); } } if (cart.InventoryTrimmed) { pnlInventoryTrimmedError.Visible = true; InventoryTrimmedError.Text = AppLogic.GetString("shoppingcart.aspx.1", SkinID, ThisCustomer.LocaleSetting); } if (cart.MinimumQuantitiesUpdated) { pnlMinimumQuantitiesUpdatedError.Visible = true; MinimumQuantitiesUpdatedError.Text = AppLogic.GetString("shoppingcart.aspx.5", SkinID, ThisCustomer.LocaleSetting); } Decimal MinOrderAmount = AppLogic.AppConfigUSDecimal("CartMinOrderAmount"); if (!cart.MeetsMinimumOrderAmount(MinOrderAmount)) { pnlMeetsMinimumOrderAmountError.Visible = true; string amountFormatted = InterpriseHelper.FormatCurrencyForCustomer(MinOrderAmount, ThisCustomer.CurrencyCode); MeetsMinimumOrderAmountError.Text = String.Format(AppLogic.GetString("shoppingcart.aspx.2", SkinID, ThisCustomer.LocaleSetting), amountFormatted); } int quantityDecimalPlaces = InterpriseHelper.GetInventoryDecimalPlacesPreference(); NumberFormatInfo formatter = (new CultureInfo(ThisCustomer.LocaleSetting)).NumberFormat; // setup the formatter formatter.NumberDecimalDigits = quantityDecimalPlaces; formatter.PercentDecimalDigits = quantityDecimalPlaces; MeetsMinimumOrderQuantityError.Text = string.Empty; decimal MinQuantity = AppLogic.AppConfigUSDecimal("MinCartItemsBeforeCheckout"); if (!cart.MeetsMinimumOrderQuantity(MinQuantity)) { pnlMeetsMinimumOrderQuantityError.Visible = true; MeetsMinimumOrderQuantityError.Text = String.Format(AppLogic.GetString("shoppingcart.aspx.16", SkinID, ThisCustomer.LocaleSetting), MinQuantity.ToString(), MinQuantity.ToString()); } //ShoppingCartGif.ImageUrl = AppLogic.LocateImageURL(SkinImagePath + "ShoppingCart.gif"); CartItems.Text = cart.RenderHTMLLiteral(new MobileShoppingCartPageLiteralRenderer()); //CartSubTotal.Text = cart.RenderHTMLLiteral(new ShoppingCartPageSummaryLiteralRenderer()); if (!cart.IsEmpty()) { //ShoppingCartorderoptions_gif.ImageUrl = AppLogic.LocateImageURL(SkinImagePath + "ShoppingCartorderoptions.gif"); string strXml = String.Empty; pnlErrorMsg.Visible = true; if (AppLogic.AppConfigBool("RequireOver13Checked") && ThisCustomer.IsRegistered && !ThisCustomer.IsOver13) { btnCheckOutNowTop.Enabled = false; btnCheckOutNowBottom.Enabled = false; ErrorMsgLabel.Text = AppLogic.GetString("over13oncheckout", SkinID, ThisCustomer.LocaleSetting); return; } btnCheckOutNowBottom.Enabled = btnCheckOutNowTop.Enabled; DisplayUpsellProducts(cart); if (cart.CouponsAllowed) { pnlCoupon.Visible = true; } else { pnlCoupon.Visible = false; } if (!AppLogic.AppConfigBool("DisallowOrderNotes")) { OrderNotes.Text = cart.OrderNotes; pnlOrderNotes.Visible = true; } else { pnlOrderNotes.Visible = false; } btnCheckOutNowBottom.Visible = true; if (ThisCustomer.IsNotRegistered) { pnlCoupon.Visible = false; pnlOrderNotes.Visible = false; } } else { pnlOrderOptions.Visible = false; pnlUpsellProducts.Visible = false; pnlCoupon.Visible = false; pnlOrderNotes.Visible = false; } btnContinueShoppingTop.OnClientClick = "self.location='" + BACKURL + "'"; CartPageFooterTopic.SetContext = this; String XmlPackageName2 = AppLogic.AppConfig("XmlPackage.ShoppingCartPageFooter"); if (XmlPackageName2.Length != 0) { XmlPackage_ShoppingCartPageFooter.Text = AppLogic.RunXmlPackage(XmlPackageName2, base.GetParser, ThisCustomer, SkinID, String.Empty, null, true, true); } }