protected void btnPromitionCode_OnCommand(object sender, EventArgs e) { if (string.IsNullOrEmpty(CartContext.CartInfo.DiscountCode)) { CartContext.CartInfo.DiscountCode = txtPromotion.Text.ToLower().Trim(); lblCouponMsg.Visible = true; if (CartContext.CartInfo.DiscountCode.ToUpper() == "FIRST15" || CartContext.CartInfo.DiscountCode.ToUpper() == "VOL15") { CustomDiscountCalculator cd = new CustomDiscountCalculator(); if (cd.CalculateDiscount(CartContext.CartInfo)) { lblCouponMsg.ForeColor = System.Drawing.Color.Green; lblCouponMsg.Text = "Thank You! Your discount has been applied."; } else { CartContext.CartInfo.DiscountCode = ""; // Making sure that we dont store any invalid code so they dont get passed to motivational. lblCouponMsg.ForeColor = System.Drawing.Color.Red; lblCouponMsg.Text = "Your promo code is not eligible for this item."; } } else { if (CartContext.CartInfo.CalculateDiscount()) { lblCouponMsg.ForeColor = System.Drawing.Color.Green; lblCouponMsg.Text = "Thank You! Your discount has been applied."; } else { CartContext.CartInfo.DiscountCode = ""; // Making sure that we dont store any invalid code so they dont get passed to motivational. lblCouponMsg.ForeColor = System.Drawing.Color.Red; lblCouponMsg.Text = "Invalid Promo Code"; } } } else { lblCouponMsg.Visible = true; lblCouponMsg.ForeColor = System.Drawing.Color.Red; lblCouponMsg.Text = "<br /><br />" + CartContext.CartInfo.DiscountCode + " is already applied. You can't use two coupons with same order."; } CartContext.CartInfo.Compute(); //showorhideDiscountPanels(); BindControls(); }
public void BindControls() { if (Request["regerateurl"] == "true") { if (Request["skuid_g"] != null && Request["skuid_g"] != "") { var skus = Request["skuid_g"].ToString(); var skuids = skus.Split(','); for (int i = 0; i < skuids.Length; i++) { if (skuids[i] != "") { var flag = IsDigitsOnly(skuids[i]); if (flag) { if (Convert.ToInt32(skuids[i]) != 153 && Convert.ToInt32(skuids[i]) != 154) { ClientOrderData.CartInfo.AddOrUpdate(Convert.ToInt32(skuids[i]), 1, true, false, false); } } } } ClientOrderData.CartInfo.RemoveSku(0); } } int qty = 0; if (CartContext.CartInfo.CartItems.Count > 0) { bool mainKit = false; foreach (Sku sku in CartContext.CartInfo.CartItems) { sku.LoadAttributeValues(); if (sku.GetAttributeValue <bool>("isMainKit", false)) { mainKit = true; qty += sku.Quantity; } } if (mainKit) { dfreeGift.Visible = true; imgOffer.Visible = true; hPromoCode.Visible = true; pnlDiscount.Visible = false; if (CartContext.CartInfo.DiscountCode.Length > 0) { CartContext.CartInfo.DiscountCode = ""; CartContext.CartInfo.Compute(); } //dfreeGift.Visible = true; //imgOffer.Visible = false; //hPromoCode.Visible = false; //pnlDiscount.Visible = true; //ltQty.Text = qty.ToString(); } else { dfreeGift.Visible = false; imgOffer.Visible = false; hPromoCode.Visible = false; pnlDiscount.Visible = true; if (horizon_dots != null) { horizon_dots.Visible = false; } } rptShoppingCart.DataSource = CartContext.CartInfo.CartItems.FindAll(x => x.Visible == true); rptShoppingCart.DataBind(); //If the main kit is removed,since the promo code 'first15' must be applied to only catalog products, calling the function again to update the discount if (!string.IsNullOrEmpty(CartContext.CartInfo.DiscountCode)) { if (CartContext.CartInfo.DiscountCode.ToUpper() == "FIRST15") { CustomDiscountCalculator cd = new CustomDiscountCalculator(); cd.CalculateDiscount(CartContext.CartInfo); } } pnlTotal.Visible = true; lblSubtotal.Text = String.Format("${0:0.00}", CartContext.CartInfo.SubTotal); lblTax.Text = String.Format("${0:0.00}", CartContext.CartInfo.TaxCost); lblShipping.Text = String.Format("${0:0.00}", CartContext.CartInfo.ShippingCost); lblRushShipping.Text = String.Format("${0:0.00}", CartContext.CartInfo.RushShippingCost); lblOrderTotal.Text = String.Format("${0:0.00}", CartContext.CartInfo.Total); if (CartContext.CartInfo.DiscountCode.Length > 0) { pnlPromotionLabel.Visible = true; pnlPromotionalAmount.Visible = true; lblPromotionPrice.Text = String.Format("(${0:0.00})", CartContext.CartInfo.DiscountAmount); } ltOfferDetail.Text = OrderHelper.GetOfferDatails(); foreach (Sku sku in CartContext.CartInfo.CartItems) { sku.LoadAttributeValues(); if (!string.IsNullOrEmpty(sku.GetAttributeValue <string>("freegift_imagepath", string.Empty))) { ltImagePath.Text = sku.GetAttributeValue <string>("freegift_imagepath", string.Empty); } if (!string.IsNullOrEmpty(sku.GetAttributeValue <string>("freegift_description", string.Empty))) { ltImageDescription.Text = sku.GetAttributeValue <string>("freegift_description", string.Empty); } } //Sri Comments on 11/15: Need to Plug-in to Custom Shipping option Model SitePreference shippingGetShippingPref = CSFactory.GetCacheSitePref(); holderRushShipping.Visible = shippingGetShippingPref.IncludeRushShipping ?? false; holderRushShippingTotal.Visible = chkIncludeRushShipping.Checked = (CartContext.CartInfo.ShippingMethod == UserShippingMethodType.Rush); } else { pnlTotal.Visible = false; rptShoppingCart.Visible = false; } Session["RegenerateUrl"] = RegenerateCartUrl(); }
public void BindControls() { if (Request["regerateurl"] == "true") { if (Request["skuid_g"] != null && Request["skuid_g"] != "") { var skus = Request["skuid_g"].ToString(); var skuids = skus.Split(','); for (int i = 0; i < skuids.Length; i++) { if (skuids[i] != "") { var flag = IsDigitsOnly(skuids[i]); if (flag) { if (Convert.ToInt32(skuids[i]) != 153 && Convert.ToInt32(skuids[i]) != 154) { ClientOrderData.CartInfo.AddOrUpdate(Convert.ToInt32(skuids[i]), 1, true, false, false); } } } } ClientOrderData.CartInfo.RemoveSku(0); } } int qty = 0; if (CartContext.CartInfo.CartItems.Count > 0) { bool mainKit = false; foreach (Sku sku in CartContext.CartInfo.CartItems) { sku.LoadAttributeValues(); if (sku.GetAttributeValue <bool>("isMainKit", false)) { mainKit = true; qty += sku.Quantity; } } if (mainKit) { if (CartContext.CartInfo.DiscountCode.Length > 0) { CartContext.CartInfo.DiscountCode = ""; CartContext.CartInfo.Compute(); } //dfreeGift.Visible = true; //imgOffer.Visible = false; //hPromoCode.Visible = false; //pnlDiscount.Visible = true; //ltQty.Text = qty.ToString(); } else { } rptShoppingCart.DataSource = CartContext.CartInfo.CartItems.FindAll(x => x.Visible == true); rptShoppingCart.DataBind(); //If the main kit is removed,since the promo code 'first15' must be applied to only catalog products, calling the function again to update the discount if (!string.IsNullOrEmpty(CartContext.CartInfo.DiscountCode)) { if (CartContext.CartInfo.DiscountCode.ToUpper() == "FIRST15") { CustomDiscountCalculator cd = new CustomDiscountCalculator(); cd.CalculateDiscount(CartContext.CartInfo); } } if (CartContext.CartInfo.DiscountCode.Length > 0) { } //Sri Comments on 11/15: Need to Plug-in to Custom Shipping option Model SitePreference shippingGetShippingPref = CSFactory.GetCacheSitePref(); } else { //rptShoppingCart.Visible = false; } Session["RegenerateUrl"] = RegenerateCartUrl(); }