protected void ApplyGiftCardCouponCode() { string couponCode = this.txtGiftCardCouponCode.Text.Trim(); if (String.IsNullOrEmpty(couponCode)) { return; } bool isGiftCardValid = GiftCardHelper.IsGiftCardValid(couponCode); if (isGiftCardValid) { pnlGiftCardWarnings.Visible = false; lblGiftCardWarning.Visible = false; string couponCodesXML = string.Empty; if (NopContext.Current.User != null) { couponCodesXML = NopContext.Current.User.GiftCardCouponCodes; } couponCodesXML = GiftCardHelper.AddCouponCode(couponCodesXML, couponCode); CustomerManager.ApplyGiftCardCouponCode(couponCodesXML); this.BindData(); } else { pnlGiftCardWarnings.Visible = true; lblGiftCardWarning.Visible = true; lblGiftCardWarning.Text = GetLocaleResourceString("ShoppingCart.GiftCards.WrongGiftCard"); } }
protected void ApplyGiftCardCouponCode() { string couponCode = this.txtGiftCardCouponCode.Text.Trim(); if (String.IsNullOrEmpty(couponCode)) { return; } var cart = this.ShoppingCartService.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); if (!cart.IsRecurring) { bool isGiftCardValid = GiftCardHelper.IsGiftCardValid(couponCode); if (isGiftCardValid) { pnlGiftCardWarnings.Visible = false; lblGiftCardWarning.Visible = false; string couponCodesXML = string.Empty; if (NopContext.Current.User != null) { couponCodesXML = NopContext.Current.User.GiftCardCouponCodes; } couponCodesXML = GiftCardHelper.AddCouponCode(couponCodesXML, couponCode); this.CustomerService.ApplyGiftCardCouponCode(couponCodesXML); this.BindData(); } else { pnlGiftCardWarnings.Visible = true; lblGiftCardWarning.Visible = true; lblGiftCardWarning.Text = GetLocaleResourceString("ShoppingCart.GiftCards.WrongGiftCard"); } } else { pnlGiftCardWarnings.Visible = true; lblGiftCardWarning.Visible = true; lblGiftCardWarning.Text = GetLocaleResourceString("ShoppingCart.GiftCards.DontWorkWithAutoshipProducts"); } }