Ejemplo n.º 1
0
        /// <summary>
        /// Populates the shopping cart.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="session">The session.</param>
        private void PopulateShoppingCart(HttpContext context, ICustomerSession session)
        {
            var set = session.GetCustomerTagSet();

            // cart total
            var helper = new CartHelper(CartHelper.CartName);

            if (!helper.IsEmpty)
            {
                set.Add(ContextFieldConstants.CartTotal, new Tag(helper.Cart.Total));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Populates the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="session">The session.</param>
        private void Populate(HttpContext context, ICustomerSession session)
        {
            var set = session.GetCustomerTagSet();

            //Profile
            if (IsRequestAuthenticated(context))
            {
                var customer = StoreHelper.UserClient.GetCurrentCustomer();
                if (customer != null)
                {
                    if (customer.BirthDate.HasValue)
                    {
                        set.Add(ContextFieldConstants.UserAge, new Tag(GetAge(customer.BirthDate.Value)));
                    }
                }
            }

            PopulateBrowserBehavior(context, session);
            PopulateShoppingCart(context, session);
            PopulateGEOLocation(context, session);
        }
        /// <summary>
        /// Populates the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="session">The session.</param>
        private void Populate(HttpContext context, ICustomerSession session)
        {
            var set = session.GetCustomerTagSet();

            //Profile
            if (IsRequestAuthenticated(context))
            {
                var customer = StoreHelper.UserClient.GetCurrentCustomer();
                if (customer != null)
                {
                    if (customer.BirthDate.HasValue)
                    {
                        set.Add(ContextFieldConstants.UserAge, new Tag(GetAge(customer.BirthDate.Value)));
                    }
                }
            }

            PopulateBrowserBehavior(context, session);
            PopulateShoppingCart(context, session);
            PopulateGEOLocation(context, session);
        }
        /// <summary>
        /// Populates the browser behavior.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="session">The session.</param>
        private void PopulateBrowserBehavior(HttpContext context, ICustomerSession session)
        {
            var set = session.GetCustomerTagSet();

            var routeValues = context.Request.RequestContext.RouteData.Values;

            if (routeValues != null)
            {
                if (routeValues.ContainsKey(Extensions.Routing.Constants.Store))
                {
                    session.StoreId = routeValues[Extensions.Routing.Constants.Store].ToString();
                }

                if (routeValues.ContainsKey(Extensions.Routing.Constants.Language))
                {
                    session.Language = routeValues[Extensions.Routing.Constants.Language].ToString();
                }

                if (routeValues.ContainsKey(Extensions.Routing.Constants.Category))
                {
                    session.CategoryOutline = routeValues[Extensions.Routing.Constants.Category].ToString();
                    session.CategoryId = session.CategoryOutline.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
                }
            }

            // search
            var search = context.Request["q"];
            if (!String.IsNullOrEmpty(search))
            {
                set.Add(ContextFieldConstants.StoreSearchPhrase, new Tag(search));
            }

            // store id
            if (!String.IsNullOrEmpty(session.StoreId))
            {
                set.Add(ContextFieldConstants.StoreId, new Tag(session.StoreId));
            }

            // category id
            if (!String.IsNullOrEmpty(session.CategoryId))
            {
                set.Add(ContextFieldConstants.CategoryId, new Tag(session.CategoryId));
            }

            //category path
            if (!String.IsNullOrEmpty(session.CategoryOutline))
            {
                set.Add(ContextFieldConstants.CategoryOutline, new Tag(session.CategoryOutline));
            }

            // language
            if (!String.IsNullOrEmpty(session.Language))
            {
                set.Add(ContextFieldConstants.Language, new Tag(session.Language));
            }

            // current URL
            set.Add(ContextFieldConstants.CurrentUrl, new Tag(context.Request.Url.AbsoluteUri));

            // referral
            var referral = GetReferralUrl(context);
            if (!String.IsNullOrEmpty(referral))
            {
                set.Add(ContextFieldConstants.ReferredUrl, new Tag(referral));

                var keywords = GetKeywords(referral);

                if (!String.IsNullOrEmpty(keywords))
                {
                    set.Add(ContextFieldConstants.InternetSearchPhrase, new Tag(keywords));
                }
            }
        }
        /// <summary>
        /// Populates the shopping cart.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="session">The session.</param>
        private void PopulateShoppingCart(HttpContext context, ICustomerSession session)
        {
            var set = session.GetCustomerTagSet();

            // cart total
            var helper = new CartHelper(CartHelper.CartName);
            if (!helper.IsEmpty)
            {
                set.Add(ContextFieldConstants.CartTotal, new Tag(helper.Cart.Total));
            }
        }
        /// <summary>
        /// Populates the geo location.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="session">The session.</param>
        private void PopulateGEOLocation(HttpContext context, ICustomerSession session)
        {
            //TODO: populate geo location information
            var set = session.GetCustomerTagSet();

        }
Ejemplo n.º 7
0
        /// <summary>
        /// Populates the browser behavior.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="session">The session.</param>
        private void PopulateBrowserBehavior(HttpContext context, ICustomerSession session)
        {
            var set = session.GetCustomerTagSet();

            var routeValues = context.Request.RequestContext.RouteData.Values;

            if (routeValues != null)
            {
                if (routeValues.ContainsKey(Extensions.Routing.Constants.Store))
                {
                    session.StoreId = routeValues[Extensions.Routing.Constants.Store].ToString();
                }

                if (routeValues.ContainsKey(Extensions.Routing.Constants.Language))
                {
                    session.Language = routeValues[Extensions.Routing.Constants.Language].ToString();
                }

                if (routeValues.ContainsKey(Extensions.Routing.Constants.Category))
                {
                    session.CategoryOutline = routeValues[Extensions.Routing.Constants.Category].ToString();
                    session.CategoryId      = session.CategoryOutline.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
                }
            }

            // search
            var search = context.Request["q"];

            if (!String.IsNullOrEmpty(search))
            {
                set.Add(ContextFieldConstants.StoreSearchPhrase, new Tag(search));
            }

            // store id
            if (!String.IsNullOrEmpty(session.StoreId))
            {
                set.Add(ContextFieldConstants.StoreId, new Tag(session.StoreId));
            }

            // category id
            if (!String.IsNullOrEmpty(session.CategoryId))
            {
                set.Add(ContextFieldConstants.CategoryId, new Tag(session.CategoryId));
            }

            //category path
            if (!String.IsNullOrEmpty(session.CategoryOutline))
            {
                set.Add(ContextFieldConstants.CategoryOutline, new Tag(session.CategoryOutline));
            }

            // language
            if (!String.IsNullOrEmpty(session.Language))
            {
                set.Add(ContextFieldConstants.Language, new Tag(session.Language));
            }

            // current URL
            set.Add(ContextFieldConstants.CurrentUrl, new Tag(context.Request.Url.AbsoluteUri));

            // referral
            var referral = GetReferralUrl(context);

            if (!String.IsNullOrEmpty(referral))
            {
                set.Add(ContextFieldConstants.ReferredUrl, new Tag(referral));

                var keywords = GetKeywords(referral);

                if (!String.IsNullOrEmpty(keywords))
                {
                    set.Add(ContextFieldConstants.InternetSearchPhrase, new Tag(keywords));
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Populates the geo location.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="session">The session.</param>
 private void PopulateGEOLocation(HttpContext context, ICustomerSession session)
 {
     //TODO: populate geo location information
     var set = session.GetCustomerTagSet();
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Populates the browser behavior.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="session">The session.</param>
        private void PopulateBrowserBehavior(HttpContext context, ICustomerSession session)
        {
            var set = session.GetCustomerTagSet();

            // search
            var search = context.Request["q"];
            if (!String.IsNullOrEmpty(search))
            {
                set.Add(ContextFieldConstants.StoreSearchPhrase, new Tag(search));
            }

            // store id
            if (!String.IsNullOrEmpty(session.StoreId))
            {
                set.Add(ContextFieldConstants.StoreId, new Tag(session.StoreId));
            }

            // category id
            if (!String.IsNullOrEmpty(session.CategoryId))
            {
                set.Add(ContextFieldConstants.CategoryId, new Tag(session.CategoryId));
            }

            // current URL
            set.Add(ContextFieldConstants.CurrentUrl, new Tag(context.Request.Url.AbsoluteUri));

            // referral
            var referral = GetReferralUrl(context);
            if (!String.IsNullOrEmpty(referral))
            {
                set.Add(ContextFieldConstants.ReferredUrl, new Tag(referral));

                var keywords = GetKeywords(referral);

                if (!String.IsNullOrEmpty(keywords))
                {
                    set.Add(ContextFieldConstants.InternetSearchPhrase, new Tag(keywords));
                }
            }
        }