コード例 #1
0
        private void InitializeShoppingCart()
        {
            _cart = new InterpriseShoppingCart(base.EntityHelpers, ThisCustomer.SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true);
            string couponCode = ThisCustomer.CouponCode;

            _cart.BuildSalesOrderDetails(false, true, couponCode);
            _cartHasCouponAndIncludesFreeShipping = _cart.CouponIncludesFreeShipping(couponCode);
        }
コード例 #2
0
        protected void btnPayPalExpressCheckout_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            if (!ThisCustomer.IsRegistered &&
                (AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout") && AppLogic.AppConfigBool("PayPalCheckout.AllowAnonCheckout")))
            {
                Response.Redirect("checkoutanon.aspx?checkout=true&checkouttype=pp");
            }
            else
            {
                // Get IS Cart ready
                ProcessCart(false);

                if (cart == null)
                {
                    cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, String.Empty, false, true);
                }

                cart.BuildSalesOrderDetails(false, false);

                ThisCustomer.ThisCustomerSession["paypalfrom"] = "shoppingcart";
                Response.Redirect(PayPalExpress.CheckoutURL(cart));
            }
        }
コード例 #3
0
        private void InitializeShoppingCart()
        {
            _cart = new InterpriseShoppingCart(base.EntityHelpers, ThisCustomer.SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true);
            if (_cart.CartItems.Count > 0)
            {
                _cart.BuildSalesOrderDetails();
                _cartHasCouponAndIncludesFreeShipping = _cart.CouponIncludesFreeShipping();
            }
            else
            {
                Response.Redirect("shoppingcart.aspx");
            }

            if (_cart.InventoryTrimmed)
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("shoppingcart.aspx.1", SkinID, ThisCustomer.LocaleSetting, true)));
            }

            string couponCode = string.Empty;
            string error      = string.Empty;

            bool hasCoupon = _cart.HasCoupon(ref couponCode);

            if (hasCoupon && _cart.IsCouponValid(ThisCustomer, couponCode, ref error))
            {
                panelCoupon.Visible   = true;
                litCouponEntered.Text = couponCode;
            }
            else
            {
                panelCoupon.Visible = false;
                if (!error.IsNullOrEmptyTrimmed())
                {
                    Response.Redirect("shoppingcart.aspx?resetlinkback=1&discountvalid=false");
                }
            }
        }
コード例 #4
0
        private void InitializeShoppingCart()
        {
            _cart = new InterpriseShoppingCart(base.EntityHelpers, ThisCustomer.SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true);

            string couponCode = string.Empty;
            bool   hasCoupon  = _cart.HasCoupon(ref couponCode);

            if (hasCoupon)
            {
                panelCoupon.Visible   = true;
                litCouponEntered.Text = couponCode;
            }
            else
            {
                panelCoupon.Visible = false;
            }

            try
            {
                // Always compute the vat since we need to display the vat even if the the vat enabled = true
                _cart.BuildSalesOrderDetails(false, true, couponCode);
                _cartHasCouponAndIncludesFreeShipping = _cart.CouponIncludesFreeShipping(couponCode);
            }
            catch (InvalidOperationException ex)
            {
                if (ex.Message == AppLogic.GetString("shoppingcart.cs.35", 1, ThisCustomer.LocaleSetting, true))
                {
                    Response.Redirect("shoppingcart.aspx?resetlinkback=1&discountvalid=false");
                }
                else
                {
                    throw ex;
                }
            }
            catch (Exception ex) { throw ex; }
        }
コード例 #5
0
        private void InitializePageContent()
        {
            int AgeWishListDays = AppLogic.AppConfigUSInt("AgeWishListDays");

            if (AgeWishListDays == 0)
            {
                AgeWishListDays = 7;
            }

            ShoppingCart.Age(ThisCustomer.CustomerID, AgeWishListDays, CartTypeEnum.WishCart);

            if (cart == null)
            {
                cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.WishCart, String.Empty, false, true);
            }

            string XmlPackageName = AppLogic.AppConfig("XmlPackage.WishListPageHeader");

            if (XmlPackageName.Length != 0)
            {
                throw new NotImplementedException("Not yet ported");
            }

            string CartTopControlLinesXmlPackage = AppLogic.AppConfig("XmlPackage.WishListPageTopControlLines");

            if (CartTopControlLinesXmlPackage.Length != 0)
            {
                XmlPackage_WishListPageTopControlLines.Text    = AppLogic.RunXmlPackage(CartTopControlLinesXmlPackage, base.GetParser, ThisCustomer, SkinID, String.Empty, null, true, true);
                XmlPackage_WishListPageTopControlLines.Visible = true;
            }
            else
            {
                pnlTopControlLines.Visible = true;
                btnContinueShopping1.Text  = AppLogic.GetString("shoppingcart.cs.12", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
                btnContinueShopping1.Attributes.Add("onclick", "self.location='" + BACKURL + "';");
                if (!cart.IsEmpty())
                {
                    btnUpateWishList1.Text = AppLogic.GetString("shoppingcart.cs.32", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
                }
                else
                {
                    btnUpateWishList1.Visible = false;
                }
            }

            //tblWishList.Attributes.Add("style", "border-style: solid; border-width: 0px; border-color: #" + AppLogic.AppConfig("HeaderBGColor"));
            //tblWishListBox.Attributes.Add("style", AppLogic.AppConfig("BoxFrameStyle"));
            //wishlist_gif.ImageUrl = AppLogic.LocateImageURL("skins/Skin_" + SkinID.ToString() + "/images/wishlist.gif");

            string CartItemsXmlPackage = AppLogic.AppConfig("XmlPackage.WishListPageItems");

            if (CartItemsXmlPackage.Length != 0)
            {
                CartItems.Text = AppLogic.RunXmlPackage(CartItemsXmlPackage, base.GetParser, ThisCustomer, SkinID, String.Empty, null, true, true);
            }
            else
            {
                CartItems.Text = cart.RenderHTMLLiteral(new MobileWishListPageLiteralRenderer());
            }

            string CartBottomControlLinesXmlPackage = AppLogic.AppConfig("XmlPackage.WishListPageBottomControlLines");

            if (CartBottomControlLinesXmlPackage.Length != 0)
            {
                Xml_WishListPageBottomControlLines.Text    = AppLogic.RunXmlPackage(CartBottomControlLinesXmlPackage, base.GetParser, ThisCustomer, SkinID, String.Empty, null, true, true);
                Xml_WishListPageBottomControlLines.Visible = true;
            }
            else
            {
                pnlBottomControlLines.Visible = true;
                btnContinueShopping2.Text     = AppLogic.GetString("shoppingcart.cs.12", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
                btnContinueShopping2.Attributes.Add("onclick", "self.location='" + BACKURL + "'");
                if (!cart.IsEmpty())
                {
                    btnUpateWishList2.Text = AppLogic.GetString("shoppingcart.cs.32", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
                }
                else
                {
                    btnUpateWishList2.Visible = false;
                }
            }

            string XmlPackageName2 = AppLogic.AppConfig("XmlPackage.WishListPageFooter");

            if (XmlPackageName2.Length != 0)
            {
                Xml_WishListPageFooter.Text = AppLogic.RunXmlPackage(XmlPackageName2, base.GetParser, ThisCustomer, SkinID, String.Empty, null, true, true);
            }

            GetJSFunctions();
        }
コード例 #6
0
    public void ProcessRequest(HttpContext context)
    {
        var ThisCustomer = ((InterpriseSuiteEcommercePrincipal)context.User).ThisCustomer;

        var m_PayPalExpress = new PayPalExpress();
        //Get PayPal info
        var PayPalDetails         = m_PayPalExpress.GetExpressCheckoutDetails(context.Request.QueryString["token"]).GetExpressCheckoutDetailsResponseDetails;
        var paypalShippingAddress = Address.New(ThisCustomer, AddressTypes.Shipping);

        if (PayPalDetails.PayerInfo.Address.Name.IsNullOrEmptyTrimmed() && (PayPalDetails.PayerInfo.Address.Street1.IsNullOrEmptyTrimmed() || PayPalDetails.PayerInfo.Address.Street2.IsNullOrEmptyTrimmed()) &&
            PayPalDetails.PayerInfo.Address.CityName.IsNullOrEmptyTrimmed() && PayPalDetails.PayerInfo.Address.StateOrProvince.IsNullOrEmptyTrimmed() && PayPalDetails.PayerInfo.Address.PostalCode.IsNullOrEmptyTrimmed() &&
            PayPalDetails.PayerInfo.Address.CountryName.ToString().IsNullOrEmptyTrimmed() || PayPalDetails.PayerInfo.ContactPhone.IsNullOrEmptyTrimmed())
        {
            paypalShippingAddress = ThisCustomer.PrimaryShippingAddress;
        }
        else
        {
            string streetAddress = PayPalDetails.PayerInfo.Address.Street1 + (!PayPalDetails.PayerInfo.Address.Street2.IsNullOrEmptyTrimmed() ? Environment.NewLine : String.Empty) + PayPalDetails.PayerInfo.Address.Street2;
            string sql           = String.Empty;
            if (ThisCustomer.IsRegistered)
            {
                sql = String.Format("SELECT COUNT(ShipToCode) AS N FROM CustomerShipTo where Address = {0} and City = {1} and State = {2} and PostalCode = {3} and Country = {4} and ShipToName = {5} and CustomerCode = {6}",
                                    streetAddress.ToDbQuote(), PayPalDetails.PayerInfo.Address.CityName.ToDbQuote(), PayPalDetails.PayerInfo.Address.StateOrProvince.ToDbQuote(), PayPalDetails.PayerInfo.Address.PostalCode.ToDbQuote(),
                                    AppLogic.ResolvePayPalAddressCode(PayPalDetails.PayerInfo.Address.CountryName).ToString().ToDbQuote(), PayPalDetails.PayerInfo.Address.Name.ToDbQuote(), ThisCustomer.CustomerCode.ToDbQuote());
            }
            else
            {
                sql = String.Format("SELECT COUNT(1) AS N FROM EcommerceAddress where ShipToAddress = {0} and ShipToCity = {1} and ShipToState = {2} and ShipToPostalCode = {3} and ShipToCountry = {4} and ShipToName = {5} and CustomerID = {6}",
                                    streetAddress.ToDbQuote(), PayPalDetails.PayerInfo.Address.CityName.ToDbQuote(), PayPalDetails.PayerInfo.Address.StateOrProvince.ToDbQuote(), PayPalDetails.PayerInfo.Address.PostalCode.ToDbQuote(),
                                    AppLogic.ResolvePayPalAddressCode(PayPalDetails.PayerInfo.Address.CountryName).ToString().ToDbQuote(), PayPalDetails.PayerInfo.Address.Name.ToDbQuote(), ThisCustomer.CustomerCode.ToDbQuote());

                paypalShippingAddress.EMail      = ThisCustomer.IsRegistered ? ThisCustomer.EMail : ThisCustomer.GetAnonEmail();
                paypalShippingAddress.Name       = PayPalDetails.PayerInfo.Address.Name;
                paypalShippingAddress.Address1   = PayPalDetails.PayerInfo.Address.Street1 + (PayPalDetails.PayerInfo.Address.Street2 != String.Empty ? Environment.NewLine : String.Empty) + PayPalDetails.PayerInfo.Address.Street2;
                paypalShippingAddress.City       = PayPalDetails.PayerInfo.Address.CityName;
                paypalShippingAddress.State      = PayPalDetails.PayerInfo.Address.StateOrProvince;
                paypalShippingAddress.PostalCode = PayPalDetails.PayerInfo.Address.PostalCode;
                paypalShippingAddress.Country    = AppLogic.ResolvePayPalAddressCode(PayPalDetails.PayerInfo.Address.CountryName.ToString());
                paypalShippingAddress.Phone      = PayPalDetails.PayerInfo.ContactPhone ?? String.Empty;
            }

            int isAddressExists = DB.GetSqlN(sql);

            if (AppLogic.AppConfigBool("PayPalCheckout.RequireConfirmedAddress") || isAddressExists == 0)
            {
                ServiceFactory.GetInstance <ICustomerService>().UpdateCustomerNotesWhenPaypalAddressIsUsed();
            }
        }

        ThisCustomer.PrimaryShippingAddress = paypalShippingAddress;
        paypalShippingAddress.Save();

        string redirectUrl = String.Empty;

        //Checking for redirectURL of PayPal -- Express Checkout button in Shopping Cart page or PayPal Radio Button in Payment Page
        if (Customer.Current.ThisCustomerSession["paypalfrom"] == "shoppingcart" || Customer.Current.ThisCustomerSession["paypalfrom"] == "checkoutanon")
        {
            redirectUrl = "checkoutshipping.aspx?PayPal=True&token=" + context.Request.QueryString["token"];
        }
        else
        {
            if (AppLogic.AppConfigBool("Checkout.UseOnePageCheckout"))
            {
                if (!AppLogic.AppConfigBool("Checkout.UseOnePageCheckout.UseFinalReviewOrderPage"))
                {
                    //Insert PayPal call here for response - For authorize and capture of order from paypal inside IS
                    ThisCustomer.ThisCustomerSession["paypalfrom"] = "onepagecheckout";
                    string  OrderNumber     = String.Empty;
                    string  status          = String.Empty;
                    string  receiptCode     = String.Empty;
                    var     billingAddress  = ThisCustomer.PrimaryBillingAddress;
                    Address shippingAddress = null;
                    var     cart            = new InterpriseShoppingCart(null, ThisCustomer.SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, String.Empty, false, true);
                    if (cart.IsNoShippingRequired())
                    {
                        cart.BuildSalesOrderDetails(false, true);
                    }
                    else
                    {
                        cart.BuildSalesOrderDetails();
                    }

                    if (!AppLogic.AppConfigBool("PayPalCheckout.OverrideAddress"))
                    {
                        if (!cart.HasShippableComponents())
                        {
                            shippingAddress = ThisCustomer.PrimaryShippingAddress;
                        }
                        else
                        {
                            if (ThisCustomer.IsRegistered)
                            {
                                var GetShippingAddress = new Address()
                                {
                                    Name           = PayPalDetails.PayerInfo.Address.Name,
                                    Address1       = PayPalDetails.PayerInfo.Address.Street1 + (PayPalDetails.PayerInfo.Address.Street2 != String.Empty ? Environment.NewLine : String.Empty) + PayPalDetails.PayerInfo.Address.Street2,
                                    City           = PayPalDetails.PayerInfo.Address.CityName,
                                    State          = PayPalDetails.PayerInfo.Address.StateOrProvince,
                                    PostalCode     = PayPalDetails.PayerInfo.Address.PostalCode,
                                    Country        = AppLogic.ResolvePayPalAddressCode(PayPalDetails.PayerInfo.Address.CountryName.ToString()),
                                    CountryISOCode = AppLogic.ResolvePayPalAddressCode(PayPalDetails.PayerInfo.Address.Country.ToString()),
                                    Phone          = PayPalDetails.PayerInfo.ContactPhone ?? String.Empty
                                };
                                shippingAddress = GetShippingAddress;
                            }
                            else
                            {
                                shippingAddress = paypalShippingAddress;
                            }
                        }
                    }

                    var    doExpressCheckoutResp = m_PayPalExpress.DoExpressCheckoutPayment(PayPalDetails.Token, PayPalDetails.PayerInfo.PayerID, OrderNumber, cart);
                    string result = String.Empty;
                    if (doExpressCheckoutResp.Errors != null && !doExpressCheckoutResp.Errors[0].ErrorCode.IsNullOrEmptyTrimmed())
                    {
                        if (AppLogic.AppConfigBool("ShowGatewayError"))
                        {
                            result = String.Format(AppLogic.GetString("shoppingcart.aspx.27", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), doExpressCheckoutResp.Errors[0].ErrorCode, doExpressCheckoutResp.Errors[0].LongMessage);
                        }
                        else
                        {
                            result = AppLogic.GetString("shoppingcart.aspx.28", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
                        }

                        context.Response.Redirect("shoppingcart.aspx?ErrorMsg=" + result.ToUrlEncode(), false);
                        return;
                    }
                    else
                    {
                        Gateway gatewayToUse = null;
                        var     payPalResp   = new GatewayResponse(String.Empty)
                        {
                            AuthorizationCode    = doExpressCheckoutResp.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].TransactionID,
                            TransactionResponse  = doExpressCheckoutResp.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].PaymentStatus.ToString(),
                            Details              = doExpressCheckoutResp.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].PaymentStatus.ToString(),
                            AuthorizationTransID = doExpressCheckoutResp.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].TransactionID
                        };

                        InterpriseHelper.UpdateCustomerPaymentTerm(ThisCustomer, DomainConstants.PAYMENT_METHOD_CREDITCARD);
                        status = cart.PlaceOrder(gatewayToUse, billingAddress, shippingAddress, ref OrderNumber, ref receiptCode, true, true, payPalResp, true, false);

                        if (status != AppLogic.ro_OK)
                        {
                            ThisCustomer.IncrementFailedTransactionCount();
                            if (ThisCustomer.FailedTransactionCount >= AppLogic.AppConfigUSInt("MaxFailedTransactionCount"))
                            {
                                cart.ClearTransaction();
                                ThisCustomer.ResetFailedTransactionCount();
                                context.Response.Redirect("orderfailed.aspx");
                            }
                            ThisCustomer.ClearTransactions(false);
                            context.Response.Redirect("checkout1.aspx?paymentterm=" + ThisCustomer.PaymentTermCode + "&errormsg=" + status.ToUrlEncode());
                        }

                        AppLogic.ClearCardNumberInSession(ThisCustomer);
                        ThisCustomer.ClearTransactions(true);

                        context.Response.Redirect(String.Format("orderconfirmation.aspx?ordernumber={0}", OrderNumber.ToUrlEncode()));
                    }
                }
                else
                {
                    InterpriseHelper.UpdateCustomerPaymentTerm(ThisCustomer, DomainConstants.PAYMENT_METHOD_CREDITCARD);
                    redirectUrl = "checkoutreview.aspx?PayPal=True&token=" + context.Request.QueryString["token"];
                }
            }
            else
            {
                InterpriseHelper.UpdateCustomerPaymentTerm(ThisCustomer, DomainConstants.PAYMENT_METHOD_CREDITCARD);
                redirectUrl = "checkoutreview.aspx?PayPal=True&token=" + context.Request.QueryString["token"];
            }
        }

        context.Response.Redirect(redirectUrl);
    }
コード例 #7
0
        public void ProcessCart(bool DoingFullCheckout)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            ThisCustomer.RequireCustomerRecord();
            CartTypeEnum cte = CartTypeEnum.ShoppingCart;

            if (CommonLogic.QueryStringCanBeDangerousContent("CartType").Length != 0)
            {
                cte = (CartTypeEnum)CommonLogic.QueryStringUSInt("CartType");
            }
            cart = new InterpriseShoppingCart(null, 1, ThisCustomer, cte, string.Empty, false, true);

            if (!Page.IsPostBack)
            {
                string couponCode = string.Empty;
                if (cart.HasCoupon(ref couponCode))
                {
                    CouponCode.Text = couponCode;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(CouponCode.Text))
                {
                    cart.ClearCoupon();
                }
            }

            // check if credit on hold
            if (ThisCustomer.IsCreditOnHold)
            {
                Response.Redirect("shoppingcart.aspx");
            }

            if (cart.IsEmpty())
            {
                // can't have this at this point:
                switch (cte)
                {
                case CartTypeEnum.ShoppingCart:
                    Response.Redirect("shoppingcart.aspx");
                    break;

                case CartTypeEnum.WishCart:
                    Response.Redirect("wishlist.aspx");
                    break;

                case CartTypeEnum.GiftRegistryCart:
                    Response.Redirect("giftregistry.aspx");
                    break;

                default:
                    Response.Redirect("shoppingcart.aspx");
                    break;
                }
            }

            //Make it a method
            UpdateCartItems();

            // save coupon code, no need to reload cart object
            // will update customer record also:
            if (cte == CartTypeEnum.ShoppingCart)
            {
                if (!string.IsNullOrEmpty(CouponCode.Text))
                {
                    string errorMessage = string.Empty;
                    if (cart.IsCouponValid(ThisCustomer, CouponCode.Text, ref errorMessage))
                    {
                        cart.ApplyCoupon(CouponCode.Text);
                    }
                    else
                    {
                        // NULL out the coupon for this cusotmer...
                        InterpriseHelper.ClearCustomerCoupon(ThisCustomer.CustomerCode, ThisCustomer.IsRegistered);

                        ErrorMsgLabel.Text = errorMessage;
                        CouponCode.Text    = string.Empty;
                        return;
                    }
                }

                // check for upsell products
                if (CommonLogic.FormCanBeDangerousContent("Upsell").Length != 0)
                {
                    foreach (string s in CommonLogic.FormCanBeDangerousContent("Upsell").Split(','))
                    {
                        int ProductID = Localization.ParseUSInt(s);
                        if (ProductID == 0)
                        {
                            continue;
                        }

                        string itemCode = InterpriseHelper.GetInventoryItemCode(ProductID);
                        string shippingAddressID;

                        shippingAddressID = CommonLogic.IIF(ThisCustomer.IsNotRegistered, string.Empty, ThisCustomer.PrimaryShippingAddressID);

                        var umInfo = InterpriseHelper.GetItemDefaultUnitMeasure(itemCode);
                        cart.AddItem(ThisCustomer, shippingAddressID, itemCode, ProductID, 1, umInfo.Code, CartTypeEnum.ShoppingCart);
                    }
                }

                bool hasCheckedOptions = false;

                if (pnlOrderOptions.Visible)
                {
                    // Process the Order Options
                    foreach (RepeaterItem ri in OrderOptionsList.Items)
                    {
                        hasCheckedOptions = true;
                        DataCheckBox cbk = (DataCheckBox)ri.FindControl("OrderOptions");
                        if (cbk.Checked)
                        {
                            string      itemCode  = (string)cbk.Data;
                            HiddenField hfCounter = ri.FindControl("hfItemCounter") as HiddenField;
                            TextBox     txtNotes  = ri.FindControl("txtOrderOptionNotes") as TextBox;

                            string strNotes = HttpUtility.HtmlEncode(txtNotes.Text);
                            string notes    = CommonLogic.IIF((strNotes != null), CommonLogic.CleanLevelOne(strNotes), string.Empty);

                            //check the length of order option notes
                            //should not exceed 1000 characters including spaces
                            int maxLen = 1000;
                            if (notes.Length > maxLen)
                            {
                                notes = notes.Substring(0, maxLen);
                            }

                            string unitMeasureCode = string.Empty;

                            // check if the item has only 1 unit measure
                            // hence it's rendered as a label
                            // else it would be rendered as a drop down list
                            Label lblUnitMeasureCode = ri.FindControl("lblUnitMeasureCode") as Label;
                            if (null != lblUnitMeasureCode && lblUnitMeasureCode.Visible)
                            {
                                unitMeasureCode = lblUnitMeasureCode.Text;
                            }
                            else
                            {
                                // it's rendered as combobox because the item has multiple unit measures configured
                                DropDownList cboUnitMeasureCode = ri.FindControl("cboUnitMeasureCode") as DropDownList;
                                if (null != cboUnitMeasureCode && cboUnitMeasureCode.Visible)
                                {
                                    unitMeasureCode = cboUnitMeasureCode.SelectedValue;
                                }
                            }

                            if (CommonLogic.IsStringNullOrEmpty(unitMeasureCode))
                            {
                                throw new ArgumentException("Unit Measure not specified!!!");
                            }

                            //check if this Order Option has Restricted Quantity and Minimum Order Qty set.
                            decimal itemQuantity = 1;

                            using (var con = DB.NewSqlConnection())
                            {
                                con.Open();
                                using (var reader = DB.GetRSFormat(con, "SELECT iw.RestrictedQuantity, iw.MinOrderQuantity FROM InventoryItem i with (NOLOCK) INNER JOIN InventoryItemWebOption iw with (NOLOCK) ON i.ItemCode = iw.ItemCode AND iw.WebsiteCode = {0} WHERE i.ItemCode = {1}", DB.SQuote(InterpriseHelper.ConfigInstance.WebSiteCode), DB.SQuote(itemCode)))
                                {
                                    if (reader.Read())
                                    {
                                        string  restrictedQuantitiesValue = DB.RSField(reader, "RestrictedQuantity");
                                        decimal minimumOrderQuantity      = Convert.ToDecimal(DB.RSFieldDecimal(reader, "MinOrderQuantity"));
                                        if (!CommonLogic.IsStringNullOrEmpty(restrictedQuantitiesValue))
                                        {
                                            string[] quantityValues = restrictedQuantitiesValue.Split(',');
                                            if (quantityValues.Length > 0)
                                            {
                                                int  ctr  = 0;
                                                bool loop = true;
                                                while (loop)
                                                {
                                                    int    quantity      = 0;
                                                    string quantityValue = quantityValues[ctr];
                                                    if (int.TryParse(quantityValue, out quantity))
                                                    {
                                                        if (quantity >= minimumOrderQuantity)
                                                        {
                                                            itemQuantity = quantity;
                                                            loop         = false;
                                                        }
                                                    }
                                                    ctr++;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (minimumOrderQuantity > 0)
                                            {
                                                itemQuantity = minimumOrderQuantity;
                                            }
                                        }
                                    }
                                }
                            }
                            // Add the selected Order Option....
                            Guid cartItemId = Guid.Empty;
                            cart.AddItem(ThisCustomer, ThisCustomer.PrimaryShippingAddressID, itemCode, int.Parse(hfCounter.Value), itemQuantity, unitMeasureCode, CartTypeEnum.ShoppingCart);
                        }
                    }
                }

                if (hasCheckedOptions)
                {
                    //refresh the option items
                    RenderOrderOptions();
                }

                if (OrderNotes.Visible)
                {
                    string sOrderNotes = CommonLogic.CleanLevelOne(OrderNotes.Text);
                    //check the length of order notes
                    //should not exceed 255 characters including spaces
                    if (sOrderNotes.Length > DomainConstants.ORDER_NOTE_MAX_LENGTH)
                    {
                        sOrderNotes = sOrderNotes.Substring(0, DomainConstants.ORDER_NOTE_MAX_LENGTH);
                    }

                    DB.ExecuteSQL(
                        String.Format("UPDATE Customer SET Notes = {0} WHERE CustomerCode = {1}",
                                      sOrderNotes.ToDbQuote(),
                                      ThisCustomer.CustomerCode.ToDbQuote())
                        );
                }
            }
            bool validated = true;

            if (cart.InventoryTrimmed)
            {
                // inventory got adjusted, send them back to the cart page to confirm the new values!
                ErrorMsgLabel.Text += Server.UrlDecode(AppLogic.GetString("shoppingcart.cs.43", SkinID, ThisCustomer.LocaleSetting));
                validated           = false;
            }
            cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true);

            if (AppLogic.AppConfigBool("ShowShipDateInCart") && AppLogic.AppConfigBool("ShowStockHints"))
            {
                cart.BuildSalesOrderDetails();
            }

            if (cte == CartTypeEnum.WishCart)
            {
                Response.Redirect("wishlist.aspx");
            }
            if (cte == CartTypeEnum.GiftRegistryCart)
            {
                Response.Redirect("giftregistry.aspx");
            }

            if (DoingFullCheckout)
            {
                if (!cart.MeetsMinimumOrderAmount(AppLogic.AppConfigUSDecimal("CartMinOrderAmount")))
                {
                    validated = false;
                }

                if (!cart.MeetsMinimumOrderQuantity(AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout")))
                {
                    validated = false;
                }

                string couponCode         = string.Empty;
                string couponErrorMessage = string.Empty;
                if (cart.HasCoupon(ref couponCode) && !cart.IsCouponValid(ThisCustomer, couponCode, ref couponErrorMessage))
                {
                    validated = false;
                }

                //One page checkout is not implemented in mobile.

                //if (AppLogic.AppConfigBool("Checkout.UseOnePageCheckout") && !cart.HasMultipleShippingAddresses())
                //{
                //    Response.Redirect("checkout1.aspx");
                //}

                if (validated)
                {
                    if (ThisCustomer.IsRegistered && (ThisCustomer.PrimaryBillingAddressID == string.Empty)) // || !ThisCustomer.HasAtLeastOneAddress()
                    {
                        Response.Redirect("selectaddress.aspx?add=true&setPrimary=true&checkout=true&addressType=Billing");
                    }

                    if (ThisCustomer.IsRegistered && (ThisCustomer.PrimaryShippingAddressID == string.Empty)) //  || !ThisCustomer.HasAtLeastOneAddress()
                    {
                        Response.Redirect("selectaddress.aspx?add=true&setPrimary=true&checkout=False&addressType=Shipping");
                    }

                    if (ThisCustomer.IsNotRegistered || ThisCustomer.PrimaryBillingAddressID == string.Empty || ThisCustomer.PrimaryShippingAddressID == string.Empty || !ThisCustomer.HasAtLeastOneAddress())
                    {
                        Response.Redirect("checkoutanon.aspx?checkout=true");
                    }
                    else
                    {
                        if (AppLogic.AppConfigBool("SkipShippingOnCheckout") ||
                            !cart.HasShippableComponents())
                        {
                            cart.MakeShippingNotRequired();
                            Response.Redirect("checkoutpayment.aspx");
                        }

                        if ((cart.HasMultipleShippingAddresses() && cart.NumItems() <= AppLogic.MultiShipMaxNumItemsAllowed() && cart.CartAllowsShippingMethodSelection))
                        {
                            Response.Redirect("checkoutshippingmult.aspx");
                        }
                        else
                        {
                            Response.Redirect("checkoutshipping.aspx");
                        }
                    }
                }
                InitializePageContent();
            }
        }
コード例 #8
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            SetCustomerSkinID();

            SkinImagePath = "skins/skin_" + SkinID.ToString() + "/images/";
            this.RequireCustomerRecord();
            RequireSecurePage();
            SectionTitle = AppLogic.GetString("AppConfig.CartPrompt", SkinID, ThisCustomer.LocaleSetting);
            ClearErrors();

            if (!this.IsPostBack)
            {
                string returnurl = CommonLogic.QueryStringCanBeDangerousContent("ReturnUrl");
                if (returnurl.IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1)
                {
                    throw new ArgumentException("SECURITY EXCEPTION");
                }
                ViewState["returnurl"] = returnurl;
                InitializePageContent();
            }

            //for optimization
            string[] formkeys = Request.Form.AllKeys;
            if (formkeys.Any(k => k.Contains("bt_Delete")))
            {
                ProcessCart(false);
                ProcessDelete();
                RenderOrderOptions();
            }
            InitializePageContent();

            //foreach (string s in formkeys)
            //{
            //    if (s != "bt_Delete") { continue; }
            //    ProcessCart(false);
            //    InitializePageContent();
            //}

            //Check if alternate checkout methods are supported (PayPal and GoogleCheckout)
            if (AppLogic.IsSupportedAlternateCheckout)
            {
                //note false just to disable the section
                //modified for mobile design
                AlternativeCheckouts.Visible = true;

                //Set the image url for the google button.
                if (AppLogic.AppConfigBool("GoogleCheckout.UseSandbox"))
                {
                    //modified for mobile design
                    btnGoogleCheckout.ImageUrl = string.Format(AppLogic.AppConfig("GoogleCheckout.SandBoxCheckoutButton"),
                                                               AppLogic.AppConfig("GoogleCheckout.SandboxMerchantId"));
                }
                else
                {
                    //modified for mobile design
                    btnGoogleCheckout.ImageUrl = string.Format(AppLogic.AppConfig("GoogleCheckout.LiveCheckoutButton"),
                                                               AppLogic.AppConfig("GoogleCheckout.MerchantId"));
                }

                //modified for mobile design

                bool hidePaypalOptionIfMultiShip = !(cart.HasMultipleShippingAddresses());

                if (AppLogic.AppConfigBool("PayPalCheckout.ShowOnCartPage") && hidePaypalOptionIfMultiShip)
                {
                    PayPalExpressSpan.Visible = true;
                }

                //modified for mobile design
                if (AppLogic.AppConfigBool("GoogleCheckout.ShowOnCartPage"))
                {
                    GoogleCheckoutSpan.Visible = InterpriseShoppingCart.IsWebCheckOutIncluded("Google");
                }

                //modified for mobile design
                if (cart != null && cart.IsShipSeparatelyCount() > 0)
                {
                    GoogleCheckoutSpan.Visible = false;
                }
            }

            //modified for mobile design
            //if no alternative methods are visible, hide the whole row
            AlternativeCheckouts.Visible = (PayPalExpressSpan.Visible || GoogleCheckoutSpan.Visible);
            if (!AppLogic.IsSupportedAlternateCheckout && AlternativeCheckouts.Visible == true)
            {
                ErrorMsgLabel.Text           = PayPalExpress.ErrorMsg;
                AlternativeCheckouts.Visible = false;
            }

            HeaderMsg.SetContext           = this;
            CartPageFooterTopic.SetContext = this;
        }
コード例 #9
0
 private void InitializeShoppingCart()
 {
     _cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true);
 }
コード例 #10
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");
            _checkoutType = CommonLogic.QueryStringCanBeDangerousContent("checkoutType");

            RequireSecurePage();

            SectionTitle = AppLogic.GetString("checkoutanon.aspx.1", SkinID, ThisCustomer.LocaleSetting, true);

            // -----------------------------------------------------------------------------------------------
            // NOTE ON PAGE LOAD LOGIC:
            // We are checking here for required elements to allowing the customer to stay on this page.
            // Many of these checks may be redundant, and they DO add a bit of overhead in terms of db calls, but ANYTHING really
            // could have changed since the customer was on the last page. Remember, the web is completely stateless. Assume this
            // page was executed by ANYONE at ANYTIME (even someone trying to break the cart).
            // It could have been yesterday, or 1 second ago, and other customers could have purchased limitied inventory products,
            // coupons may no longer be valid, etc, etc, etc...
            // -----------------------------------------------------------------------------------------------
            ThisCustomer.RequireCustomerRecord();

            cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, String.Empty, false, true);

            if (cart.IsEmpty())
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (cart.InventoryTrimmed)
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("shoppingcart.aspx.1", SkinID, ThisCustomer.LocaleSetting, true)));
            }

            if (!cart.MeetsMinimumOrderAmount(AppLogic.AppConfigUSDecimal("CartMinOrderAmount")))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (!cart.MeetsMinimumOrderWeight(AppLogic.AppConfigUSDecimal("MinOrderWeight")))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (!cart.MeetsMinimumOrderQuantity(AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout")))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            CheckoutMap.HotSpots[0].AlternateText = AppLogic.GetString("checkoutanon.aspx.2", SkinID, ThisCustomer.LocaleSetting, true);

            Teaser.SetContext = this;

            if (AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout"))
            {
                PasswordOptionalPanel.Visible = true;
            }

            ErrorMsgLabel.Text = "";
            if (!IsPostBack)
            {
                InitializePageContent();
            }

            if (AppLogic.AppConfigBool("SecurityCodeRequiredOnStoreLogin"))
            {
                // Create a random code and store it in the Session object.
                SecurityImage.Visible = true;
                SecurityCode.Visible  = true;

                trSecurityCodeText.Visible  = true;
                trSecurityCodeImage.Visible = true;

                Label4.Visible = true;
                if (!IsPostBack)
                {
                    SecurityImage.ImageUrl = "Captcha.ashx?id=1";
                }
                else
                {
                    SecurityImage.ImageUrl = "Captcha.ashx?id=2";
                }
            }
        }
コード例 #11
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            Customer ThisCustomer = ((InterpriseSuiteEcommercePrincipal)Context.User).ThisCustomer;

            ThisCustomer.RequireCustomerRecord();

            InterpriseShoppingCart cart = new InterpriseShoppingCart(null, 1, ThisCustomer, CartTypeEnum.ShoppingCart, String.Empty, false, true);

            bool redirectToWishList = false;

            foreach (string key in Request.Form.AllKeys)
            {
                try
                {
                    if (!key.StartsWith("ProductID"))
                    {
                        continue;
                    }

                    // retrieve the item counter
                    // This may look obvious 4 but we want to make it expressive
                    string itemCounterValue     = Request.Form[key];
                    string quantityOrderedValue = Request.Form["Quantity"];

                    if (string.IsNullOrEmpty(quantityOrderedValue))
                    {
                        quantityOrderedValue = Request.Form["Quantity_" + itemCounterValue];

                        if (!string.IsNullOrEmpty(quantityOrderedValue))
                        {
                            quantityOrderedValue = quantityOrderedValue.Split(',')[0];
                        }
                    }

                    int counter         = 0;
                    int quantityOrdered = 0;
                    if (!string.IsNullOrEmpty(itemCounterValue) &&
                        int.TryParse(itemCounterValue, out counter) &&
                        !string.IsNullOrEmpty(quantityOrderedValue) &&
                        int.TryParse(quantityOrderedValue, out quantityOrdered) &&
                        quantityOrdered > 0)
                    {
                        string unitMeasureFieldKey   = "UnitMeasureCode_" + counter.ToString();
                        bool   useDefaultUnitMeasure = string.IsNullOrEmpty(Request.Form[unitMeasureFieldKey]);

                        string isWishListFieldKey = "IsWishList_" + counter.ToString();
                        bool   isWishList         = !string.IsNullOrEmpty(Request.Form[isWishListFieldKey]);
                        redirectToWishList = isWishList;

                        // we've got a valid counter
                        string itemCode = string.Empty;

                        using (var con = DB.NewSqlConnection())
                        {
                            con.Open();
                            using (var reader = DB.GetRSFormat(con, "SELECT ItemCode FROM InventoryItem with (NOLOCK) WHERE Counter = {0}", counter))
                            {
                                if (reader.Read())
                                {
                                    itemCode = DB.RSField(reader, "ItemCode");
                                }
                            }
                        }

                        if (!string.IsNullOrEmpty(itemCode))
                        {
                            UnitMeasureInfo?umInfo = null;

                            if (!useDefaultUnitMeasure)
                            {
                                umInfo = InterpriseHelper.GetItemUnitMeasure(itemCode, Request.Form[unitMeasureFieldKey]);
                            }

                            if (null == umInfo && useDefaultUnitMeasure)
                            {
                                umInfo = InterpriseHelper.GetItemDefaultUnitMeasure(itemCode);
                            }

                            if (null != umInfo && umInfo.HasValue)
                            {
                                if (isWishList)
                                {
                                    cart.CartType = CartTypeEnum.WishCart;
                                }
                                cart.AddItem(ThisCustomer, ThisCustomer.PrimaryShippingAddressID, itemCode, counter, quantityOrdered, umInfo.Value.Code, CartTypeEnum.ShoppingCart); //, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, CartTypeEnum.ShoppingCart, false, false, string.Empty, decimal.Zero);
                            }
                        }
                    }
                }
                catch
                {
                    // do nothing, add the items that we can
                }
            }

            if (redirectToWishList)
            {
                Response.Redirect("WishList.aspx");
            }
            else
            {
                Response.Redirect("ShoppingCart.aspx?add=true");
            }
        }
コード例 #12
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            if (AppLogic.AppConfigBool("RequireOver13Checked") && !ThisCustomer.IsOver13)
            {
                Response.Redirect("shoppingcart.aspx?errormsg=" + Server.UrlEncode(AppLogic.GetString("checkout.over13required", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
            }

            if (ThisCustomer.IsCreditOnHold)
            {
                Response.Redirect("shoppingcart.aspx");
            }

            RequireSecurePage();

            // -----------------------------------------------------------------------------------------------
            // NOTE ON PAGE LOAD LOGIC:
            // We are checking here for required elements to allowing the customer to stay on this page.
            // Many of these checks may be redundant, and they DO add a bit of overhead in terms of db calls, but ANYTHING really
            // could have changed since the customer was on the last page. Remember, the web is completely stateless. Assume this
            // page was executed by ANYONE at ANYTIME (even someone trying to break the cart).
            // It could have been yesterday, or 1 second ago, and other customers could have purchased limitied inventory products,
            // coupons may no longer be valid, etc, etc, etc...
            // -----------------------------------------------------------------------------------------------
            ThisCustomer.RequireCustomerRecord();
            if (ThisCustomer.IsNotRegistered &&
                !AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout") &&
                !AppLogic.AppConfigBool("Checkout.UseOnePageCheckout"))
            {
                Response.Redirect("createaccount.aspx?checkout=true");
            }
            if (ThisCustomer.IsRegistered && (ThisCustomer.PrimaryBillingAddressID == String.Empty || ThisCustomer.PrimaryShippingAddressID == String.Empty))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("checkoutpayment.aspx.1", SkinID, ThisCustomer.LocaleSetting)));
            }

            SectionTitle = AppLogic.GetString("checkoutreview.aspx.1", SkinID, ThisCustomer.LocaleSetting);
            cart         = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, String.Empty, false, true);

            if (cart.IsEmpty())
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (cart.HasRegistryItems())
            {
                Response.Redirect("shoppingcart.aspx");
            }

            if (cart.InventoryTrimmed)
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("shoppingcart.aspx.1", SkinID, ThisCustomer.LocaleSetting)));
            }

            string couponCode         = string.Empty;
            string couponErrorMessage = string.Empty;

            if (cart.HasCoupon(ref couponCode) && !cart.IsCouponValid(ThisCustomer, couponCode, ref couponErrorMessage))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&discountvalid=false");
            }

            if (!cart.MeetsMinimumOrderAmount(AppLogic.AppConfigUSDecimal("CartMinOrderAmount")))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (!cart.MeetsMinimumOrderQuantity(AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout")))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (!IsPostBack)
            {
                InitializePageContent();
            }
        }
コード例 #13
0
        protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
        {
            string  CustomerID  = ThisCustomer.CustomerCode;
            string  OrderNumber = CommonLogic.QueryStringCanBeDangerousContent("OrderNumber", true);
            bool    isvalid     = false;
            decimal ordertotal  = decimal.Zero;

            //don't allow the customer any further if they dont own this order.
            foreach (string salesOrderToCheck in OrderNumber.Split(','))
            {
                if (ThisCustomer.IsUnregisteredAnonymous ||
                    !ThisCustomer.OwnsThisOrder(salesOrderToCheck))
                {
                    Response.Redirect(SE.MakeDriverLink("ordernotfound"));
                }
            }

            //Assign anonymous id as customer id for report generation.
            if (!ThisCustomer.IsRegistered && OrderNumber != "")
            {
                ThisCustomer.EMail        = ThisCustomer.GetAnonEmail();
                ThisCustomer.CustomerCode = ThisCustomer.AnonymousCustomerCode;
                CustomerID = ThisCustomer.CustomerCode;
            }

            // WRITE OUT ANY HEADER CHECKOUT SEQUENCE GRAPHIC:
            if (CustomerID != string.Empty && OrderNumber != string.Empty)
            {
                string multiOrderNumber = DB.SQuote(OrderNumber);
                multiOrderNumber = "(" + multiOrderNumber.Replace(",", "','") + ")";

                bool hasFailedTransaction = false;
                hasFailedTransaction = DB.GetSqlN(string.Format("SELECT COUNT(*) AS N FROM  CustomerSalesOrder with (NOLOCK) WHERE SalesOrderCode IN {0} AND IsVoided = 1", multiOrderNumber)) > 0;

                using (var con = DB.NewSqlConnection())
                {
                    con.Open();
                    using (var rs = DB.GetRSFormat(con, "select SUM(TotalRate)AS TotalRate from CustomerSalesOrder with (NOLOCK) where BillToCode=" + DB.SQuote(CustomerID) + " and SalesOrderCode IN" + multiOrderNumber))
                    {
                        if (rs.Read())
                        {
                            ordertotal = DB.RSFieldDecimal(rs, "TotalRate");
                            isvalid    = true;
                        }
                    }
                }

                if (isvalid)
                {
                    string PM = AppLogic.CleanPaymentMethod(ThisCustomer.PaymentMethod);
                    bool   AlreadyConfirmed    = false;
                    string StoreName           = AppLogic.AppConfig("StoreName");
                    bool   UseLiveTransactions = AppLogic.AppConfigBool("UseLiveTransactions");

                    var cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, String.Empty, false, true);

                    bool multipleAttachment = false;
                    if (multiOrderNumber.IndexOf(',') != -1)
                    {
                        multipleAttachment = true;
                    }

                    //Send mail.
                    foreach (string salesOrderToEmail in OrderNumber.Split(','))
                    {
                        if (ThisCustomer.PaymentTermCode.ToUpper() != "REQUEST QUOTE" && ThisCustomer.PaymentTermCode.ToUpper() != "PURCHASE ORDER")
                        {
                            AppLogic.SendOrderEMail(ThisCustomer, cart, salesOrderToEmail, false, PM, true, multipleAttachment);
                        }
                        else
                        {
                            AppLogic.SendOrderEMail(ThisCustomer, cart, salesOrderToEmail, false, PM, multipleAttachment);
                        }
                    }

                    string XmlPackageName = AppLogic.AppConfig("XmlPackage.OrderConfirmationPage");
                    if (XmlPackageName.Length == 0)
                    {
                        XmlPackageName = "orderconfirmation.xml.config";
                    }

                    if (XmlPackageName.Length != 0)
                    {
                        string[] salesOrderCodes = OrderNumber.Split(',');
                        for (int ctr = 0; ctr < salesOrderCodes.Length; ctr++)
                        {
                            string salesOrderCode = salesOrderCodes[ctr];

                            var runtimeParams = new List <XmlPackageParam>();
                            if (ctr == 0)
                            {
                                runtimeParams.Add(new XmlPackageParam("IncludeHeader", true.ToString().ToLowerInvariant()));
                            }
                            else
                            {
                                runtimeParams.Add(new XmlPackageParam("IncludeHeader", false.ToString().ToLowerInvariant()));
                            }

                            string salesOrderStage = string.Empty;
                            using (var con = DB.NewSqlConnection())
                            {
                                con.Open();
                                using (var rs = DB.GetRSFormat(con, "SELECT Stage from CustomerSalesOrderWorkFlowView where salesOrderCode=" + DB.SQuote(salesOrderCode)))
                                {
                                    if (rs.Read())
                                    {
                                        salesOrderStage = DB.RSField(rs, "Stage");
                                    }
                                }
                            }

                            runtimeParams.Add(new XmlPackageParam("OrderNumber", salesOrderCode));
                            runtimeParams.Add(new XmlPackageParam("SalesOrderStage", salesOrderStage));

                            if (ThisCustomer.PaymentTermCode.ToUpper() == "REQUEST QUOTE")
                            {
                                runtimeParams.Add(new XmlPackageParam("PaymentMethod", "REQUESTQUOTE"));
                            }
                            else if (ThisCustomer.PaymentTermCode.ToUpper() == "PURCHASE ORDER")
                            {
                                runtimeParams.Add(new XmlPackageParam("PaymentMethod", "PURCHASEORDER"));
                            }
                            else
                            {
                                runtimeParams.Add(new XmlPackageParam("PaymentMethod", ThisCustomer.PaymentMethod));
                            }
                            runtimeParams.Add(new XmlPackageParam("Email", ThisCustomer.EMail));

                            if (ctr + 1 == salesOrderCodes.Length)
                            {
                                runtimeParams.Add(new XmlPackageParam("IncludeFooter", true.ToString().ToLowerInvariant()));
                                runtimeParams.Add(new XmlPackageParam("WriteFailedTransaction", hasFailedTransaction.ToString().ToLowerInvariant()));
                            }
                            else
                            {
                                runtimeParams.Add(new XmlPackageParam("IncludeFooter", false.ToString().ToLowerInvariant()));
                            }

                            writer.Write(AppLogic.RunXmlPackage(XmlPackageName, base.GetParser, ThisCustomer, SkinID, String.Empty, runtimeParams, true, true));
                        }
                    }

                    if (!AlreadyConfirmed && AppLogic.AppConfigBool("GoogleAnalytics.ConversionTracking"))
                    {
                        string test = AppLogic.GAEcommerceTracking(ThisCustomer);
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), DB.GetNewGUID(), test, false);
                    }
                }
                else
                {
                    writer.Write("<div align=\"center\">");
                    writer.Write("<br/><br/><br/><br/><br/>");
                    writer.Write(AppLogic.GetString("orderconfirmation.aspx.15", SkinID, ThisCustomer.LocaleSetting));
                    writer.Write("<br/><br/><br/><br/><br/>");
                    writer.Write("</div>");
                }
            }
            else
            {
                writer.Write("<p><b>Error: Invalid Customer ID or Invalid Order Number</b></p>");
            }

            if (!ThisCustomer.IsRegistered || AppLogic.AppConfigBool("ForceSignoutOnOrderCompletion"))
            {
                //Setting cookie values for anonymous receipts. We should look into a more secure way to do this, but for now
                //it's better than what we had.
                AppLogic.SetSessionCookie("ContactGUID", ThisCustomer.ContactGUID.ToString());
                AppLogic.SetSessionCookie("OrderNumber", CommonLogic.QueryStringCanBeDangerousContent("OrderNumber", true));

                if (AppLogic.AppConfigBool("SiteDisclaimerRequired"))
                {
                    AppLogic.SetSessionCookie("SiteDisclaimerAccepted", String.Empty);
                }
                //V3_9 Kill the Authentication ticket.
                Session.Clear();
                Session.Abandon();
                ThisCustomer.ThisCustomerSession.Clear();
                FormsAuthentication.SignOut();
            }
        }
コード例 #14
0
 public void btnUpateWishList1_Click(object sender, EventArgs e)
 {
     UpdateWishList();
     cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.WishCart, String.Empty, false, true);
     InitializePageContent();
 }
コード例 #15
0
        protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
        {
            String CustomerID  = ThisCustomer.CustomerCode;
            String OrderNumber = CommonLogic.QueryStringCanBeDangerousContent("OrderNumber", true);
            bool   isvalid     = false;

            decimal orderTotal     = Decimal.Zero;
            decimal freightRate    = Decimal.Zero;
            decimal freightTaxRate = Decimal.Zero;
            decimal taxRate        = Decimal.Zero;

            //don't allow the customer any further if they dont own this order.
            foreach (string salesOrderToCheck in OrderNumber.Split(','))
            {
                if (ThisCustomer.IsUnregisteredAnonymous ||
                    !ThisCustomer.OwnsThisOrder(salesOrderToCheck))
                {
                    Response.Redirect(SE.MakeDriverLink("ordernotfound"));
                }
            }

            //Assign anonymous id as customer id for report generation.
            if (!ThisCustomer.IsRegistered && OrderNumber != "")
            {
                ThisCustomer.EMail        = ThisCustomer.GetAnonEmail();
                ThisCustomer.CustomerCode = ThisCustomer.AnonymousCustomerCode;
                CustomerID = ThisCustomer.CustomerCode;
            }

            // ----------------------------------------------------------------------------------------
            // WRITE OUT ANY HEADER CHECKOUT SEQUENCE GRAPHIC:
            // ----------------------------------------------------------------------------------------
            writer.Write("<div align=\"center\">");
            writer.Write("<img src=\"" + AppLogic.LocateImageURL("skins/skin_" + SkinID.ToString() + "/images/step_6.gif") + "\" width=\"550\" height=\"54\" border=\"0\" >\n");
            writer.Write("</div>");

            if (CustomerID != String.Empty && OrderNumber != String.Empty)
            {
                String multiOrderNumber = DB.SQuote(OrderNumber);
                multiOrderNumber = "(" + multiOrderNumber.Replace(",", "','") + ")";

                bool hasFailedTransaction = false;
                hasFailedTransaction = DB.GetSqlN(string.Format("SELECT COUNT(*) AS N FROM  CustomerSalesOrder with (NOLOCK) WHERE SalesOrderCode IN {0} AND IsVoided = 1", multiOrderNumber)) > 0;

                using (SqlConnection con = DB.NewSqlConnection())
                {
                    con.Open();
                    using (IDataReader rs = DB.GetRSFormat(con, "select SUM(TotalRate) AS TotalRate, SUM(FreightRate) AS FreightRate, SUM(TaxRate) AS TaxRate FROM CustomerSalesOrder with (NOLOCK) where BillToCode=" + DB.SQuote(CustomerID) + " and SalesOrderCode IN" + multiOrderNumber))
                    {
                        if (rs.Read())
                        {
                            orderTotal  = rs.ToRSFieldDecimal("TotalRate");
                            freightRate = rs.ToRSFieldDecimal("FreightRate");
                            taxRate     = rs.ToRSFieldDecimal("TaxRate");

                            isvalid = true;
                        }
                    }
                }

                if (isvalid)
                {
                    String PM = AppLogic.CleanPaymentMethod(ThisCustomer.PaymentMethod);

                    bool AlreadyConfirmed = false;

                    String StoreName           = AppLogic.AppConfig("StoreName");
                    bool   UseLiveTransactions = AppLogic.AppConfigBool("UseLiveTransactions");

                    InterpriseShoppingCart cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, String.Empty, false, true);

                    bool multipleAttachment = false;
                    if (multiOrderNumber.IndexOf(',') != -1)
                    {
                        multipleAttachment = true;
                    }

                    //Send mail.
                    foreach (string salesOrderToEmail in OrderNumber.Split(','))
                    {
                        if (ThisCustomer.PaymentTermCode.ToUpper() != "REQUEST QUOTE" && ThisCustomer.PaymentTermCode.ToUpper() != "PURCHASE ORDER")
                        {
                            AppLogic.SendOrderEMail(ThisCustomer, cart, salesOrderToEmail, false, PM, true, multipleAttachment);
                        }
                        else
                        {
                            //This will only send email to admin.
                            AppLogic.SendOrderEMail(ThisCustomer, cart, salesOrderToEmail, false, PM, multipleAttachment);
                        }
                    }

                    String XmlPackageName = AppLogic.AppConfig("XmlPackage.OrderConfirmationPage");
                    if (XmlPackageName.Length == 0)
                    {
                        XmlPackageName = "page.orderconfirmation.xml.config";
                    }

                    if (XmlPackageName.Length != 0)
                    {
                        string[] salesOrderCodes = OrderNumber.Split(',');
                        for (int ctr = 0; ctr < salesOrderCodes.Length; ctr++)
                        {
                            string salesOrderCode = salesOrderCodes[ctr];

                            List <XmlPackageParam> runtimeParams = new List <XmlPackageParam>();
                            if (ctr == 0)
                            {
                                runtimeParams.Add(new XmlPackageParam("IncludeHeader", true.ToString().ToLowerInvariant()));
                            }
                            else
                            {
                                runtimeParams.Add(new XmlPackageParam("IncludeHeader", false.ToString().ToLowerInvariant()));
                            }

                            string salesOrderStage = string.Empty;

                            using (SqlConnection con = DB.NewSqlConnection())
                            {
                                con.Open();
                                using (IDataReader rs = DB.GetRSFormat(con, "SELECT Stage from CustomerSalesOrderWorkFlowView where salesOrderCode=" + DB.SQuote(salesOrderCode)))
                                {
                                    if (rs.Read())
                                    {
                                        salesOrderStage = DB.RSField(rs, "Stage");
                                    }
                                }
                            }

                            runtimeParams.Add(new XmlPackageParam("OrderNumber", salesOrderCode));
                            runtimeParams.Add(new XmlPackageParam("SalesOrderStage", salesOrderStage));

                            if (ThisCustomer.PaymentTermCode.ToUpper() == "REQUEST QUOTE")
                            {
                                runtimeParams.Add(new XmlPackageParam("PaymentMethod", "REQUESTQUOTE"));
                            }
                            else if (ThisCustomer.PaymentTermCode.ToUpper() == "PURCHASE ORDER")
                            {
                                runtimeParams.Add(new XmlPackageParam("PaymentMethod", "PURCHASEORDER"));
                            }
                            else
                            {
                                runtimeParams.Add(new XmlPackageParam("PaymentMethod", ThisCustomer.PaymentMethod));
                            }
                            runtimeParams.Add(new XmlPackageParam("Email", ThisCustomer.EMail));

                            if (ctr + 1 == salesOrderCodes.Length)
                            {
                                runtimeParams.Add(new XmlPackageParam("IncludeFooter", true.ToString().ToLowerInvariant()));
                                runtimeParams.Add(new XmlPackageParam("WriteFailedTransaction", hasFailedTransaction.ToString().ToLowerInvariant()));
                            }
                            else
                            {
                                runtimeParams.Add(new XmlPackageParam("IncludeFooter", false.ToString().ToLowerInvariant()));
                            }

                            writer.Write(AppLogic.RunXmlPackage(XmlPackageName, base.GetParser, ThisCustomer, SkinID, String.Empty, runtimeParams, true, true));
                        }
                    }

                    #region Conversion

                    if (!AlreadyConfirmed)
                    {
                        #region Google Analytics

                        if (AppLogic.AppConfigBool("GoogleAnalytics.ConversionTracking"))
                        {
                            ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), DB.GetNewGUID(), AppLogic.GAEcommerceTracking(ThisCustomer), false);
                        }
                        // Google AdWords conversion trackng code (added 7-10-14)
                        {
                            writer.Write("<!-- Google Code for Sales Conversion Page --> <script type='text/javascript'> ");
                            writer.Write("/* <![CDATA[ */ ");
                            writer.Write("var google_conversion_id = 986485184; ");
                            writer.Write("var google_conversion_language = 'en'; ");
                            writer.Write("var google_conversion_format = '2'; ");
                            writer.Write("var google_conversion_color = 'ffffff'; ");
                            writer.Write("var google_conversion_label = 'u53nCIDh8woQwKOy1gM'; var google_conversion_value = 1.00; var google_remarketing_only = false; ");
                            writer.Write("/* ]]> */ ");
                            writer.Write("</script> ");
                            writer.Write("<script type='text/javascript' ");
                            writer.Write("src='//www.googleadservices.com/pagead/conversion.js'> ");
                            writer.Write("</script> ");
                            writer.Write("<noscript> ");
                            writer.Write("<div style='display:inline;''> ");
                            writer.Write("<img height='1' width='1' style='border-style:none;' alt='' ");
                            writer.Write("src='//www.googleadservices.com/pagead/conversion/986485184/?value=1.00&amp;label=u53nCIDh8woQwKOy1gM&amp;guid=ON&amp;script=0'/> ");
                            writer.Write("</div> ");
                            writer.Write("</noscript> ");
                        }

                        #endregion

                        #region Buy Safe
                        string buySafeSealHash       = AppLogic.AppConfig("BuySafe.SealHash");
                        bool   registerBuySafeScript = AppLogic.AppConfigBool("BuySafe.Enabled") && !buySafeSealHash.IsNullOrEmptyTrimmed() && !ThisCustomer.EMail.IsNullOrEmptyTrimmed();

                        if (registerBuySafeScript)
                        {
                            var buySAFEGuaranteed = new StringBuilder();

                            buySAFEGuaranteed.Append("<span id='BuySafeGuaranteeSpan'></span>");
                            buySAFEGuaranteed.Append("<script src='//seal.buysafe.com/private/rollover/rollover.js'></script>");
                            buySAFEGuaranteed.Append("<script type='text/javascript'>");
                            buySAFEGuaranteed.Append(" if(window.buySAFE && buySAFE.Loaded){ ");
                            buySAFEGuaranteed.AppendFormat(" buySAFE.Hash = '{0}'; ", buySafeSealHash);
                            buySAFEGuaranteed.AppendFormat(" buySAFE.Guarantee.order = '{0}'; ", OrderNumber);
                            buySAFEGuaranteed.AppendFormat(" buySAFE.Guarantee.subtotal = {0}; ", orderTotal);
                            buySAFEGuaranteed.AppendFormat(" buySAFE.Guarantee.email = '{0}'; ", ThisCustomer.EMail);
                            buySAFEGuaranteed.Append(" WriteBuySafeGuarantee('JavaScript'); ");
                            buySAFEGuaranteed.Append(" }");
                            buySAFEGuaranteed.Append("</script>");

                            ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), DB.GetNewGUID(), buySAFEGuaranteed.ToString(), false);
                        }
                        #endregion

                        #region Bing Ads

                        string bingAdsTrackingScript = AppLogic.GetBingAdsTrackingScript(AppLogic.BING_ADS_TYPE_CONVERSION, freightRate, taxRate, orderTotal);

                        if (!bingAdsTrackingScript.IsNullOrEmptyTrimmed())
                        {
                            ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), DB.GetNewGUID(), bingAdsTrackingScript, false);
                        }

                        #endregion
                    }

                    #endregion
                }
                else
                {
                    writer.Write("<div align=\"center\">");
                    writer.Write("<br/><br/><br/><br/><br/>");
                    writer.Write(AppLogic.GetString("orderconfirmation.aspx.15", SkinID, ThisCustomer.LocaleSetting));
                    writer.Write("<br/><br/><br/><br/><br/>");
                    writer.Write("</div>");
                }
            }
            else
            {
                writer.Write("<p><b>Error: Invalid Customer ID or Invalid Order Number</b></p>");
            }

            if (!ThisCustomer.IsRegistered || AppLogic.AppConfigBool("ForceSignoutOnOrderCompletion"))
            {
                //Setting cookie values for anonymous receipts. We should look into a more secure way to do this, but for now
                //it's better than what we had.
                AppLogic.SetSessionCookie("ContactGUID", ThisCustomer.ContactGUID.ToString());
                AppLogic.SetSessionCookie("OrderNumber", CommonLogic.QueryStringCanBeDangerousContent("OrderNumber", true));

                if (AppLogic.AppConfigBool("SiteDisclaimerRequired"))
                {
                    AppLogic.SetSessionCookie("SiteDisclaimerAccepted", String.Empty);
                }
                //V3_9 Kill the Authentication ticket.
                Session.Clear();
                Session.Abandon();
                ThisCustomer.ThisCustomerSession.Clear();
                FormsAuthentication.SignOut();
            }
        }
コード例 #16
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            this.RequireCustomerRecord();

            SectionTitle = AppLogic.GetString("wishlist.aspx.1", SkinID, ThisCustomer.LocaleSetting);

            int?moveToCartId = "MoveToCartID".ToQueryString().TryParseIntUsLocalization();

            if (moveToCartId.HasValue)
            {
                int     cartId   = moveToCartId.Value;
                decimal?quantity = "MoveToCartQty".ToQueryString().TryParseDecimalUsLocalization();

                bool   cartItemExisting  = false;
                string itemCode          = string.Empty;
                string itemType          = string.Empty;
                string unitMeasureCode   = string.Empty;
                string shippingAddressID = string.Empty;
                Guid   cartGuid          = Guid.Empty;
                int    counter           = 0;
                // NOTE :
                // Move this logic on the Shopping Cart Form

                using (var con = DB.NewSqlConnection())
                {
                    con.Open();
                    using (var reader = DB.GetRSFormat(con, "SELECT wsc.ShoppingCartRecGuid, i.Counter, i.ItemCode, i.ItemType, wsc.UnitMeasureCode, wsc.ShippingAddressID FROM EcommerceShoppingCart wsc with (NOLOCK) INNER JOIN InventoryItem i with (NOLOCK) ON i.ItemCode = wsc.ItemCode WHERE wsc.ShoppingCartRecID = {0}", cartId))
                    {
                        cartItemExisting = reader.Read();
                        if (cartItemExisting)
                        {
                            cartGuid          = DB.RSFieldGUID2(reader, "ShoppingCartRecGuid");
                            counter           = DB.RSFieldInt(reader, "Counter");
                            itemCode          = DB.RSField(reader, "ItemCode");
                            itemType          = DB.RSField(reader, "ItemType");
                            unitMeasureCode   = DB.RSField(reader, "UnitMeasureCode");
                            shippingAddressID = DB.RSField(reader, "ShippingAddressID");
                        }
                    }
                }

                if (cartItemExisting)
                {
                    var kitCartWishListComposition = KitComposition.FromCart(ThisCustomer, CartTypeEnum.WishCart, itemCode, cartGuid);
                    cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, String.Empty, false, true);

                    if (itemType == Interprise.Framework.Base.Shared.Const.ITEM_TYPE_KIT)
                    {
                        cart.AddItem(ThisCustomer,
                                     shippingAddressID,
                                     itemCode,
                                     counter,
                                     quantity.Value,
                                     unitMeasureCode,
                                     CartTypeEnum.ShoppingCart,
                                     kitCartWishListComposition);
                    }
                    else
                    {
                        cart.AddItem(ThisCustomer,
                                     shippingAddressID,
                                     itemCode,
                                     counter,
                                     quantity.Value,
                                     unitMeasureCode,
                                     CartTypeEnum.ShoppingCart);
                    }

                    ServiceFactory.GetInstance <IShoppingCartService>()
                    .ClearLineItemsAndKitComposition(new String[] { cartGuid.ToString() });
                }
                Response.Redirect("ShoppingCart.aspx");
            }

            cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.WishCart, String.Empty, false, true);

            ProcessDelete();

            if (!IsPostBack)
            {
                string returnurl = CommonLogic.QueryStringCanBeDangerousContent("ReturnUrl");

                if (returnurl.IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1)
                {
                    throw new ArgumentException("SECURITY EXCEPTION");
                }

                ViewState["returnurl"] = returnurl;
                InitializePageContent();
            }
            TopicWishListPageHeader.SetContext = this;
            TopicWishListPageFooter.SetContext = this;
        }
コード例 #17
0
        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);
            }
        }
コード例 #18
0
 private void InitializeShoppingCart()
 {
     _cart = new InterpriseShoppingCart(base.EntityHelpers, ThisCustomer.SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true);
     _cart.BuildSalesOrderDetails();
 }
コード例 #19
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            Response.Cache.SetAllowResponseInBrowserHistory(false);

            Customer ThisCustomer = ((InterpriseSuiteEcommercePrincipal)Context.User).ThisCustomer;

            ThisCustomer.RequireCustomerRecord();

            String paReq          = ThisCustomer.ThisCustomerSession["3Dsecure.paReq"];
            String PaRes          = CommonLogic.FormCanBeDangerousContent("PaRes");
            String MerchantData   = CommonLogic.FormCanBeDangerousContent("MD");
            String TransactionID  = ThisCustomer.ThisCustomerSession["3Dsecure.XID"];
            string salesOrderCode = ThisCustomer.ThisCustomerSession.Session("3Dsecure.OrderNumber");
            String ErrorDesc      = String.Empty;
            String ReturnURL      = String.Empty;

            // The PaRes should have no whitespace in it, we need to strip it out.
            PaRes = PaRes.Replace(" ", "");
            PaRes = PaRes.Replace("\r", "");
            PaRes = PaRes.Replace("\n", "");

            if (PaRes.Length != 0)
            {
                ThisCustomer.ThisCustomerSession["3Dsecure.PaRes"] = PaRes;
            }

            if (ReturnURL.Length == 0 && MerchantData != ThisCustomer.ThisCustomerSession["3Dsecure.MD"])
            {
                ReturnURL = "checkoutpayment.aspx?error=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("secureprocess.aspx.1", 1, ThisCustomer.LocaleSetting, true));
            }

            if (ReturnURL.Length == 0 && ShoppingCart.CartIsEmpty(ThisCustomer.CustomerCode, CartTypeEnum.ShoppingCart))
            {
                ReturnURL = "ShoppingCart.aspx";
            }

            if (ReturnURL.Length == 0 && CommonLogic.IsStringNullOrEmpty(salesOrderCode))
            {
                ReturnURL = "checkoutpayment.aspx?error=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("secureprocess.aspx.1", 1, ThisCustomer.LocaleSetting, true));
            }

            if (ReturnURL.Length == 0)
            {
                if (paReq.Length == 0 || TransactionID.Length == 0)
                {
                    ReturnURL = "checkoutpayment.aspx?error=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("secureprocess.aspx.1", 1, ThisCustomer.LocaleSetting, true));
                }
            }

            if (ReturnURL.Length == 0)
            {
                InterpriseShoppingCart cart = InterpriseShoppingCart.Get(ThisCustomer, CartTypeEnum.ShoppingCart, true);
                if (cart != null)
                {
                    InterpriseSuiteEcommerceCommon.Gateway gatewayToUse = null;

                    Address billingAddress  = ThisCustomer.PrimaryBillingAddress;
                    Address shippingAddress = ThisCustomer.PrimaryShippingAddress;

                    string receiptCode = TransactionID; // This is what interprise sends as Vendor Transaction Code upon Capture Process
                    string status      = cart.PlaceOrder(gatewayToUse, billingAddress, shippingAddress, ref salesOrderCode, ref receiptCode, true, true, true);

                    if (status == AppLogic.ro_OK)
                    {
                        ThisCustomer.ClearTransactions(true);

                        ReturnURL = string.Format("orderconfirmation.aspx?ordernumber={0}", Server.UrlEncode(salesOrderCode));
                    }
                    else
                    {
                        ErrorDesc = status;
                    }
                }
                else
                {
                    // ORDER CANNOT BE FOUND!!!
                    ReturnURL = "ShoppingCart.aspx";
                }
            }


            if (ReturnURL.Length == 0)
            {
                if (AppLogic.AppConfigBool("Checkout.UseOnePageCheckout"))
                {
                    ReturnURL = "checkout1.aspx?error=1&errormsg=" + Server.UrlEncode(String.Format(AppLogic.GetString("secureprocess.aspx.2", 1, ThisCustomer.LocaleSetting, true), ErrorDesc));
                }
                else
                {
                    ReturnURL = "checkoutpayment.aspx?error=1&errormsg=" + Server.UrlEncode(String.Format(AppLogic.GetString("secureprocess.aspx.2", 1, ThisCustomer.LocaleSetting, true), ErrorDesc));
                }
            }

            ThisCustomer.ThisCustomerSession["3DSecure.CustomerID"]  = String.Empty;
            ThisCustomer.ThisCustomerSession["3DSecure.OrderNumber"] = String.Empty;
            ThisCustomer.ThisCustomerSession["3DSecure.ACSUrl"]      = String.Empty;
            ThisCustomer.ThisCustomerSession["3DSecure.paReq"]       = String.Empty;
            ThisCustomer.ThisCustomerSession["3DSecure.XID"]         = String.Empty;
            ThisCustomer.ThisCustomerSession["3DSecure.MD"]          = String.Empty;
            ThisCustomer.ThisCustomerSession["3Dsecure.PaRes"]       = String.Empty;


            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");
            Response.Write("<html><head><title>3-D Secure Process</title></head><body>");
            Response.Write("<script type=\"text/javascript\">\n");
            Response.Write("top.location='" + ReturnURL + "';\n");
            Response.Write("</SCRIPT>\n");
            Response.Write("<div align=\"center\">" + String.Format(AppLogic.GetString("secureprocess.aspx.3", 1, ThisCustomer.LocaleSetting, true), ReturnURL) + "</div>");
            Response.Write("</body></html>");
        }