private void SetCart(out ClientCartContext cartContext)
        {
            cartContext = new ClientCartContext();
            cartContext.RequestParam         = CommonHelper.GetQueryString(Request.RawUrl);
            cartContext.IpAddress            = CommonHelper.IpAddress(HttpContext.Current);
            cartContext.OrderAttributeValues = new System.Collections.Generic.Dictionary <string, CSBusiness.Attributes.AttributeValue>();
            cartContext.OrderAttributeValues.Add("ref_url", new AttributeValue(ReferrerURL));
            cartContext.OrderAttributeValues.Add("landing_url", new AttributeValue(LandingPageURL));
            cartContext.OrderAttributeValues.Add("servername", new AttributeValue(ServerName));
            cartContext.VersionId = CSBasePage.GetVersion();

            if (cartContext.CartInfo == null)
            {
                cartContext.CartInfo = new CSBusiness.ShoppingManagement.Cart();
                cartContext.CartInfo.ShippingAddress = new CSBusiness.CustomerManagement.Address();
            }
        }
        protected ClientCartContext GetInitializedCart()
        {
            ClientCartContext cartContext = null;

            if (Session["ClientOrderData"] != null)
            {
                cartContext = (ClientCartContext)Session["ClientOrderData"];
            }
            if (cartContext != null && cartContext.OrderId > 0)
            {
                // This means order is already placed and user re-visited the home page again. So we should reset the data
                cartContext.ResetData();
                cartContext.OrderId = 0;
                SetCart(out cartContext);
            }
            else if (cartContext != null)
            {
                // This means that cart is set in root and redirected to some version. So if versionid is different then we should set the new landing page and new version.
                if (cartContext.VersionId != CSBasePage.GetVersion())
                {
                    if (cartContext.OrderAttributeValues != null && cartContext.OrderAttributeValues.ContainsKey("landing_url"))
                    {
                        cartContext.OrderAttributeValues.Remove("landing_url");
                        cartContext.OrderAttributeValues.Add("landing_url", new AttributeValue(LandingPageURL));
                    }
                    else
                    {
                        SetCart(out cartContext);
                    }
                    cartContext.VersionId = CSBasePage.GetVersion();
                }
            }
            else
            {
                SetCart(out cartContext);
            }

            Session["ClientOrderData"] = cartContext;
            return(cartContext);
        }