コード例 #1
0
        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");
            }
        }
コード例 #2
0
        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");
            }
        }