/// <summary>
        /// Adds to shopping cart.
        /// </summary>
        /// <param name="productCode">The product code.</param>
        /// <param name="quantity">The quantity.</param>
        public static void AddToShoppingCart(string productCode, string quantity)
        {
            Assert.ArgumentNotNullOrEmpty(productCode, "productCode");
            Assert.ArgumentNotNullOrEmpty(quantity, "quantity");

            IShoppingCartManager shoppingCartManager = Context.Entity.Resolve <IShoppingCartManager>();

            uint q;

            if (string.IsNullOrEmpty(quantity) || !uint.TryParse(quantity, out q))
            {
                shoppingCartManager.AddProduct(productCode, 1);
            }
            else
            {
                shoppingCartManager.AddProduct(productCode, q);
            }

            ShoppingCart     shoppingCart             = Context.Entity.GetInstance <ShoppingCart>();
            ShoppingCartLine existingShoppingCartLine = shoppingCart.ShoppingCartLines.FirstOrDefault(p => p.Product.Code.Equals(productCode));

            try
            {
                Tracker.StartTracking();
                AnalyticsUtil.AddToShoppingCart(existingShoppingCartLine.Product.Code, existingShoppingCartLine.Product.Title, 1, existingShoppingCartLine.Totals.PriceExVat);
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
        }
Beispiel #2
0
        /// <summary>
        /// The update shopping cart.
        /// </summary>
        protected void UpdateShoppingCart()
        {
            foreach (var product in this.UcProductsListView.GetProducts())
            {
                string productCode = product.Key;
                uint   quant       = product.Value;

                ProductLine existingProductLine = this.Cart.ShoppingCartLines.FirstOrDefault(p => p.Product.Code.Equals(productCode));

                if (existingProductLine == null)
                {
                    return;
                }

                IShoppingCartManager shoppingCartManager = Sitecore.Ecommerce.Context.Entity.Resolve <IShoppingCartManager>();
                shoppingCartManager.UpdateProductQuantity(productCode, quant);

                AnalyticsUtil.ShoppingCartItemUpdated(productCode, existingProductLine.Product.Title, quant);
            }

            Sitecore.Ecommerce.Context.Entity.SetInstance(this.Cart);

            this.UpdateTotals(this.Cart);
            this.UpdateProductLines(this.Cart);
        }
Beispiel #3
0
        /// <summary>
        /// Handles the ItemCommand event of the UcProductsListView control.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param>
        protected void UcProductsListView_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName != "Delete" || string.IsNullOrEmpty((string)e.CommandArgument))
            {
                return;
            }

            ListString listString  = new ListString((string)e.CommandArgument);
            string     productCode = listString[0];

            ProductLine existingProductLine = this.Cart.ShoppingCartLines.FirstOrDefault(p => p.Product.Code.Equals(productCode));

            if (existingProductLine != null)
            {
                AnalyticsUtil.ShoppingCartItemRemoved(productCode, existingProductLine.Product.Title, existingProductLine.Quantity);
            }

            IShoppingCartManager shoppingCartManager = Sitecore.Ecommerce.Context.Entity.Resolve <IShoppingCartManager>();

            shoppingCartManager.RemoveProductLine(productCode);

            if (this.Cart.ShoppingCartLines.Count == 0)
            {
                this.Response.Redirect(LinkManager.GetItemUrl(Sitecore.Context.Item));
            }

            Sitecore.Ecommerce.Context.Entity.SetInstance(this.Cart);

            this.UpdateTotals(this.Cart);
            this.UpdateProductLines(this.Cart);
        }
Beispiel #4
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                AnalyticsUtil.ShoppingCartViewed();

                this.btnEmptyShoppingCart.Text = Translate.Text(Texts.EmptyCart);
                this.btnUpdate.Text            = Translate.Text(Texts.UpdateCart);
                this.btnContinueShopping.Text  = Translate.Text(Texts.ContinueShopping);
            }

            if (this.Cart.ShoppingCartLines.Count == 0)
            {
                this.litStatus.Text                        = Translate.Text(Texts.TheShoppingCartIsEmpty);
                this.UcProductsListView.Visible            = false;
                this.btnUpdateContainer.Visible            = false;
                this.btnProceedToCheckoutContainer.Visible = false;
                this.btnEmptyContainer.Visible             = false;
                this.tocArea.Visible                       = false;
                this.summary.Visible                       = false;
                this.delivery.Visible                      = false;
            }

            this.UcProductsListView.Currency = this.Cart.Currency;
            this.summary.Currency            = this.Cart.Currency;
            this.delivery.Currency           = this.Cart.Currency;

            this.btnProceedToCheckout.Text    = Translate.Text(Texts.ProceedToCheckout);
            this.btnProceedToCheckout.ToolTip = Translate.Text(Texts.PleaseReadAndAcceptTheTermsAndConditionsBeforeContinuing);
            this.btnProceedToCheckout.Attributes["disabled"] = Cart.ShoppingCartLines.Count <= 0 || !this.termsOfConditions.Checked ? "disabled" : string.Empty;
        }
Beispiel #5
0
    // SETTER --------------------------------------------------------

    public static void ConfigFirstRun()
    {
        if (!PlayerPrefs.HasKey(KEY_INTBOOL_IS_FIRST_RUN))
        {
            LogUtil.PrintWarning("PlayerPrefsUtil: First time run detected. Setting config defaults.");
            AnalyticsUtil.RecordFirstRun();

            PlayerPrefs.SetInt(KEY_INTBOOL_IS_FIRST_RUN, 1);

            //AUDIO
            PlayerPrefs.SetFloat(KEY_FLOAT_AUDIO_VOLUME_BGM, TheExplorersConfig.VOLUME_DEFAULT);
            PlayerPrefs.SetFloat(KEY_FLOAT_AUDIO_VOLUME_SFX, TheExplorersConfig.VOLUME_DEFAULT);

            //SCORES
            PlayerPrefs.SetString(KEY_STRING_HIGH_SCORE_1, "");
            PlayerPrefs.SetString(KEY_STRING_HIGH_SCORE_2, "");
            PlayerPrefs.SetString(KEY_STRING_HIGH_SCORE_3, "");
            PlayerPrefs.SetString(KEY_STRING_HIGH_SCORE_4, "");
            PlayerPrefs.SetString(KEY_STRING_HIGH_SCORE_5, "");

            PlayerPrefs.SetInt(KEY_INT_HIGHEST_LEVEL_CLEARED, 0);

            PlayerPrefs.Save();
        }
        else
        {
            LogUtil.PrintInfo("PlayerPrefsUtil: This isn't the 1st time the game is ran. Ignoring config defaults.");
        }
    }
Beispiel #6
0
        public void UpdateShoppingCart(string productCode, string quantity)
        {
            Assert.ArgumentNotNullOrEmpty(productCode, "productCode");
            Assert.ArgumentNotNullOrEmpty(quantity, "quantity");

            uint q;

            if (string.IsNullOrEmpty(quantity) || !uint.TryParse(quantity, out q))
            {
                return;
            }

            IShoppingCartManager shoppingCartManager = Sitecore.Ecommerce.Context.Entity.Resolve <IShoppingCartManager>();

            shoppingCartManager.UpdateProductQuantity(productCode, q);
            try
            {
                Tracker.StartTracking();
                AnalyticsUtil.ShoppingCartUpdated();
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Handles the OnClick event of the btnLogIn control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnLogIn_OnClick(object sender, EventArgs e)
        {
            AnalyticsUtil.AuthentificationClickedLoginLink();

            GeneralSettings generalSettings = Sitecore.Ecommerce.Context.Entity.GetConfiguration <GeneralSettings>();

            this.Response.Redirect(Utils.ItemUtil.GetItemUrl(generalSettings.MainLoginLink, true));
        }
        /// <summary>
        /// Handles the Click event of the ConfirmButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void ConfirmButton_Click(object sender, EventArgs e)
        {
            AnalyticsUtil.CheckoutPaymentNext();

            PipelineArgs pipelineArgs = new PipelineArgs();

            CorePipeline.Run("paymentStarted", pipelineArgs);

            this.btnConfirm.Enabled = false;
        }
Beispiel #9
0
 public void EditShopingCartClicked()
 {
     try
     {
         Tracker.StartTracking();
         AnalyticsUtil.GoToShoppingCart();
     }
     catch (Exception ex)
     {
         LogException(ex);
     }
 }
Beispiel #10
0
        /// <summary>
        /// Gets the Friendly Url
        /// </summary>
        /// <param name="dataItem">The data item.</param>
        /// <returns>Shopping cart item friendly url.</returns>
        protected string ShoppingCartLineFriendlyUrl(object dataItem)
        {
            ShoppingCartLine shoppingCartLine = dataItem as ShoppingCartLine;

            if (shoppingCartLine == null)
            {
                Log.Warn("Product line is null.", this);
                return("-");
            }

            return(AnalyticsUtil.AddFollowListToQueryString(shoppingCartLine.FriendlyUrl, "ShoppingCartSpot"));
        }
Beispiel #11
0
 public void LoginUser()
 {
     try
     {
         Tracker.StartTracking();
         AnalyticsUtil.AuthentificationClickedLoginLink();
     }
     catch (Exception ex)
     {
         LogException(ex);
     }
 }
Beispiel #12
0
 public void ShoppingCartSpotCheckout()
 {
     try
     {
         Tracker.StartTracking();
         AnalyticsUtil.GoToCheckOut();
     }
     catch (Exception ex)
     {
         LogException(ex);
     }
 }
Beispiel #13
0
 public void SetCurrentTab(string tab)
 {
     HttpContext.Current.Session["EcProductTabName"] = tab;
     try
     {
         Tracker.StartTracking();
         AnalyticsUtil.NavigationTabSelected(tab);
     }
     catch (Exception ex)
     {
         LogException(ex);
     }
 }
Beispiel #14
0
        /// <summary>
        /// Handles the OnClick event of the btnLogOut control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnLogOut_OnClick(object sender, EventArgs e)
        {
            ICustomerManager <CustomerInfo> customerManager = Sitecore.Ecommerce.Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            AnalyticsUtil.AuthentificationUserLoggedOut(customerManager.CurrentUser.NickName);

            AuthenticationManager.Logout();

            customerManager.ResetCurrentUser();

            var url = string.Empty;

            try
            {
                if (Sitecore.Context.Item.Security.CanRead(Sitecore.Security.Accounts.User.Current))
                {
                    var qs = WebUtil.GetQueryString();

                    Item catalogItem = null;

                    using (new SecurityDisabler())
                    {
                        catalogItem = Sitecore.Ecommerce.Context.Entity.Resolve <VirtualProductResolver>().ProductCatalogItem;
                    }

                    if (catalogItem == null)
                    {
                        url = LinkManager.GetItemUrl(Sitecore.Context.Item);
                    }
                    else
                    {
                        url = Sitecore.Ecommerce.Context.Entity.Resolve <VirtualProductResolver>().GetVirtualProductUrl(catalogItem, Sitecore.Context.Item);
                    }

                    qs  = qs.TrimStart('?');
                    qs  = (qs != string.Empty) ? "?" + qs : string.Empty;
                    url = string.Concat(url, qs);
                }
                else
                {
                    url = "/";
                }
            }
            catch (Exception err)
            {
                Log.Warn(err.Message, err);
            }

            this.Response.Redirect(url);
        }
Beispiel #15
0
        /// <summary>
        /// Redirects to the login menu if the user exists.
        /// Otherwise returns an error message / exception.
        /// </summary>
        /// <param name="formid"> The formid. </param>
        /// <param name="fields"> The fields. </param>
        /// <exception cref="ValidatorException">Username or password was wrong. Please try again.</exception>
        protected override void CreateItemByFields(ID formid, AdaptedResultList fields)
        {
            AnalyticsUtil.AuthentificationClickedLoginButton();

            NameValueCollection form = new NameValueCollection();

            ActionHelper.FillFormData(form, fields, null);

            ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            if (Sitecore.Context.User.IsAuthenticated)
            {
                AuthenticationManager.Logout();
                customerManager.ResetCurrentUser();
            }

            string fullNickName = Sitecore.Context.Domain.GetFullName(form["UserName"]);
            bool   loginResult  = customerManager.LogInCustomer(fullNickName, form["Password"]);

            if (loginResult)
            {
                AnalyticsUtil.AuthentificationUserLoginSucceeded(fullNickName);

                try
                {
                    string loginPath = ItemUtil.GetNavigationLinkPath("Login");
                    if (!string.IsNullOrEmpty(loginPath))
                    {
                        HttpContext.Current.Response.Redirect(loginPath);
                    }
                    else
                    {
                        if (HttpContext.Current.Request.UrlReferrer != null)
                        {
                            HttpContext.Current.Response.Redirect(HttpContext.Current.Request.UrlReferrer.AbsolutePath);
                        }
                    }
                }
                catch (NavigateLinkNotFoundException)
                {
                    HttpContext.Current.Response.Redirect(LinkManager.GetItemUrl(Sitecore.Context.Item));
                }
            }
            else
            {
                AnalyticsUtil.AuthentificationUserLoginFailed(fullNickName);
                throw new ValidatorException("Username or password was wrong. Please try again.");
            }
        }
        /// <summary>
        /// Gets the Friendly Url
        /// </summary>
        /// <param name="dataItem">
        /// The data item.
        /// </param>
        /// <returns>
        /// Shopping cart item friendly url.
        /// </returns>
        protected string ShoppingCartLineFriendlyUrl(object dataItem)
        {
            string friendlyUrl;

            if (this.DisplayMode == OrderDisplayMode.ShoppingCart)
            {
                ShoppingCartLine shoppingCartItem = (ShoppingCartLine)dataItem;
                friendlyUrl = shoppingCartItem.FriendlyUrl;
            }
            else
            {
                OrderLine orderLine = (OrderLine)dataItem;
                friendlyUrl = orderLine.FriendlyUrl;
            }

            return(AnalyticsUtil.AddFollowListToQueryString(friendlyUrl, this.DisplayMode.ToString()));
        }
Beispiel #17
0
        public void LogOutCurrentUser()
        {
            ICustomerManager <CustomerInfo> customerManager = Sitecore.Ecommerce.Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            try
            {
                Tracker.StartTracking();
                AnalyticsUtil.AuthentificationUserLoggedOut(customerManager.CurrentUser.NickName);
            }
            catch (Exception ex)
            {
                LogException(ex);
            }

            AuthenticationManager.Logout();

            customerManager.ResetCurrentUser();
        }
Beispiel #18
0
        /// <summary>
        /// Handles the OnClick event of the btnLogOut control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnLogOut_OnClick(object sender, EventArgs e)
        {
            ICustomerManager <CustomerInfo> customerManager = Sitecore.Ecommerce.Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            AnalyticsUtil.AuthentificationUserLoggedOut(customerManager.CurrentUser.NickName);

            AuthenticationManager.Logout();

            customerManager.ResetCurrentUser();

            var url = string.Empty;

            if (Sitecore.Context.Item.Security.CanRead(User.Current))
            {
                var qs = WebUtil.GetQueryString();

                var itemUrl = Sitecore.Context.ClientData.GetValue("itempath") as string;
                if (string.IsNullOrEmpty(itemUrl))
                {
                    url = LinkManager.GetItemUrl(Sitecore.Context.Item);
                }
                else
                {
                    VirtualProductResolver virtualProductResolver = Sitecore.Ecommerce.Context.Entity.Resolve <VirtualProductResolver>();
                    var folderItem = virtualProductResolver.ProductCatalogItem;
                    if (folderItem != null)
                    {
                        url = virtualProductResolver.GetVirtualProductUrl(folderItem, Sitecore.Context.Item);
                    }
                }

                qs  = qs.TrimStart('?');
                qs  = (qs != string.Empty) ? "?" + qs : string.Empty;
                url = string.Concat(url, qs);
            }
            else
            {
                url = "/";
            }

            Response.Redirect(url);
        }
        /// <summary>
        /// Processes the specified args.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public override void Process(StartTrackingArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            string ecommerceEvent = WebUtil.GetQueryString(Settings.GetSetting("Ecommerce.Analytics.EventQueryStringKey")).Trim();

            if (string.IsNullOrEmpty(ecommerceEvent))
            {
                return;
            }

            if ((ecommerceEvent.ToLowerInvariant() != null) && (ecommerceEvent == "followlist"))
            {
                AnalyticsUtil.NavigationFollowListHit();
            }
            else
            {
                AnalyticsUtil.RegisterNoParameterEvent(ecommerceEvent);
            }
        }
Beispiel #20
0
        public void PaymentMethodChanged(string paymentMethodCode)
        {
            Assert.ArgumentNotNullOrEmpty(paymentMethodCode, "paymentMethodCode");

            IEntityProvider <PaymentSystem> provider = Sitecore.Ecommerce.Context.Entity.Resolve <IEntityProvider <PaymentSystem> >();
            PaymentSystem paymentMethod = provider.Get(paymentMethodCode);

            ShoppingCart shoppingCart = Sitecore.Ecommerce.Context.Entity.GetInstance <ShoppingCart>();

            shoppingCart.PaymentSystem = paymentMethod;
            try
            {
                Tracker.StartTracking();
                AnalyticsUtil.CheckoutPaymentMethodSelected(paymentMethod.Title, paymentMethod.Code);
            }
            catch (Exception ex)
            {
                LogException(ex);
            }

            Sitecore.Ecommerce.Context.Entity.SetInstance(shoppingCart);
        }
Beispiel #21
0
        public void CreateCustomerAccount()
        {
            ICustomerManager <CustomerInfo> manager = Sitecore.Ecommerce.Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            if (string.IsNullOrEmpty(manager.CurrentUser.Email) || Sitecore.Context.User.IsAuthenticated)
            {
                return;
            }

            manager.CreateCustomerAccount(manager.CurrentUser.Email, string.Empty, manager.CurrentUser.Email);
            manager.UpdateCustomerProfile(manager.CurrentUser);

            try
            {
                Tracker.StartTracking();
                AnalyticsUtil.AuthentificationAccountCreated();
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
        }
Beispiel #22
0
        /// <summary>
        /// Handles the Click event of the btnEmptyShoppingCart control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnEmptyShoppingCart_Click(object sender, EventArgs e)
        {
            uint       numberOfProducts    = 0;
            ListString shoppingCartContent = new ListString();

            foreach (ShoppingCartLine line in this.Cart.ShoppingCartLines)
            {
                shoppingCartContent.Add(line.Product.Code);
                numberOfProducts += line.Quantity;
            }

            AnalyticsUtil.ShoppingCartEmptied(shoppingCartContent.ToString(), numberOfProducts);

            this.Cart.ShoppingCartLines.Clear();

            ICheckOut checkOut = Sitecore.Ecommerce.Context.Entity.Resolve <ICheckOut>();

            if (checkOut is CheckOut)
            {
                ((CheckOut)checkOut).ResetCheckOut();
            }

            ItemUtil.RedirectToNavigationLink(ContinueShopping, false);
        }
        /// <summary>
        /// Deletes from shopping cart.
        /// </summary>
        /// <param name="productCode">The product code.</param>
        public static void DeleteFromShoppingCart(string productCode)
        {
            Assert.ArgumentNotNullOrEmpty(productCode, "productCode");

            ShoppingCart     shoppingCart             = Context.Entity.GetInstance <ShoppingCart>();
            ShoppingCartLine existingShoppingCartLine = shoppingCart.ShoppingCartLines.FirstOrDefault(p => p.Product.Code.Equals(productCode));

            try
            {
                if (existingShoppingCartLine != null)
                {
                    Tracker.StartTracking();
                    AnalyticsUtil.ShoppingCartProductRemoved(existingShoppingCartLine.Product.Code, existingShoppingCartLine.Product.Title, existingShoppingCartLine.Quantity);
                }
            }
            catch (Exception ex)
            {
                LogException(ex);
            }

            IShoppingCartManager shoppingCartManager = Context.Entity.Resolve <IShoppingCartManager>();

            shoppingCartManager.RemoveProduct(productCode);
        }
Beispiel #24
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (NicamHelper.SafeRequest("search") != string.Empty)
                {
                    var searchWords = NicamHelper.UrlDecode(NicamHelper.SafeRequest("search"));

                    IEnumerable <Sitecore.Ecommerce.Search.SearchResult> resultHits = new LuceneSearcher(this.BuildQuery(searchWords), "web").Search();

                    List <Sitecore.Ecommerce.Search.SearchResult> results = new List <Sitecore.Ecommerce.Search.SearchResult>();
                    foreach (Sitecore.Ecommerce.Search.SearchResult resultHit in resultHits)
                    {
                        if (resultHit == null || resultHit.ResultItem == null || resultHit.ResultItem.ItemUri == null)
                        {
                            continue;
                        }

                        if (!results.Any(r => r.ResultItem.ItemLink == resultHit.ResultItem.ItemLink) && ItemUri.Parse(resultHit.ResultItem.ItemUri).Language == Sitecore.Context.Language && ItemUri.Parse(resultHit.ParentItem.ItemUri).Language == Sitecore.Context.Language)
                        {
                            results.Add(resultHit);
                        }
                    }

                    foreach (Sitecore.Ecommerce.Search.SearchResult resultHit in results)
                    {
                        TreeNode pnode = this.linksTree.Nodes.Cast <TreeNode>().FirstOrDefault(t => t.NavigateUrl == resultHit.ParentItem.ItemLink);

                        TreeNode node = new TreeNode(resultHit.ResultItem.ItemTitle)
                        {
                            NavigateUrl = resultHit.ResultItem.ItemLink,
                            Value       = resultHit.ResultItem.ItemUri
                        };

                        if (pnode == null)
                        {
                            pnode = new TreeNode(resultHit.ParentItem.ItemTitle)
                            {
                                NavigateUrl = resultHit.ParentItem.ItemLink,
                                Value       = resultHit.ParentItem.ItemUri
                            };
                            pnode.ChildNodes.Add(node);
                            this.linksTree.Nodes.Add(pnode);
                        }
                        else
                        {
                            pnode.ChildNodes.Add(node);
                        }
                    }

                    this.bodySearch.Value = searchWords;
                    AnalyticsUtil.Search(searchWords, resultHits.Count());
                }
            }
            else
            {
                if (SearchAgainClicked() && this.bodySearch.Value != string.Empty)
                {
                    var url = NicamHelper.RedirectUrl(Consts.SearchResultPage, "search", this.bodySearch.Value);
                    //// Search Result Page via QS only. It is necessary for Print version of page
                    Response.Redirect(url);
                }
            }
        }
Beispiel #25
0
        /// <summary>
        /// Submits the specified formid.
        /// </summary>
        /// <param name="formid">The formid.</param>
        /// <param name="fields">The fields.</param>
        /// <param name="data">The data.</param>
        public void Execute(ID formid, AdaptedResultList fields, params object[] data)
        {
            if (StaticSettings.MasterDatabase == null)
            {
                Log.Warn("'Create Item' action : master database is unavailable", this);
            }

            NameValueCollection form = new NameValueCollection();

            ActionHelper.FillFormData(form, fields, this.ProcessField);

            // If username and password was given, create a user.
            if (string.IsNullOrEmpty(form["Email"]) || string.IsNullOrEmpty(form["Password"]))
            {
                return;
            }

            string name     = form["Email"].Trim();
            string password = form["Password"];
            string email    = form["Email"];

            string fullNickName = Sitecore.Context.Domain.GetFullName(name);

            ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();
            CustomerInfo customerInfo = customerManager.CreateCustomerAccount(fullNickName, password, email);

            if (customerInfo == null)
            {
                AnalyticsUtil.AuthentificationAccountCreationFailed();
                return;
            }

            foreach (string key in form.AllKeys)
            {
                customerInfo[key] = form[key];
            }

            customerInfo.BillingAddress.Name    = form["Name"];
            customerInfo.BillingAddress.Address = form["Address"];
            customerInfo.BillingAddress.Zip     = form["Zip"];
            customerInfo.BillingAddress.City    = form["City"];
            customerInfo.BillingAddress.State   = form["State"];

            if (!string.IsNullOrEmpty(form["Country"]))
            {
                IEntityProvider <Country> countryProvider = Context.Entity.Resolve <IEntityProvider <Country> >();
                customerInfo.BillingAddress.Country = countryProvider.Get(form["Country"]);
            }

            if (form["HideThisSection"] == "1")
            {
                customerInfo.ShippingAddress.Name    = form["Name"];
                customerInfo.ShippingAddress.Address = form["Address"];
                customerInfo.ShippingAddress.Zip     = form["Zip"];
                customerInfo.ShippingAddress.City    = form["City"];
                customerInfo.ShippingAddress.State   = form["State"];

                if (!string.IsNullOrEmpty(form["ShippingCountry"]))
                {
                    IEntityProvider <Country> countryProvider = Context.Entity.Resolve <IEntityProvider <Country> >();
                    customerInfo.ShippingAddress.Country = countryProvider.Get(form["ShippingCountry"]);
                }
            }
            else
            {
                EntityHelper entityHepler      = Context.Entity.Resolve <EntityHelper>();
                AddressInfo  targetAddressInfo = customerInfo.ShippingAddress;

                entityHepler.CopyPropertiesValues(customerInfo.BillingAddress, ref targetAddressInfo);
            }

            customerManager.UpdateCustomerProfile(customerInfo);
            customerManager.CurrentUser = customerInfo;

            AnalyticsUtil.AuthentificationAccountCreated();
        }
Beispiel #26
0
        /// <summary>
        /// Handles the Click event of the btnUpdate control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            AnalyticsUtil.ShoppingCartUpdated();

            this.UpdateShoppingCart();
        }
Beispiel #27
0
        /// <summary>
        /// Handles the Click event of the btnContinueShopping control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnContinueShopping_Click(object sender, EventArgs e)
        {
            AnalyticsUtil.ShoppingCartContinueShopping();

            ItemUtil.RedirectToNavigationLink(ContinueShopping, false);
        }
Beispiel #28
0
        /// <summary>
        /// Executes the specified formid.
        /// </summary>
        /// <param name="formid">The formid.</param>
        /// <param name="fields">The fields.</param>
        /// <param name="data">The data.</param>
        public override void Execute(ID formid, AdaptedResultList fields, object[] data)
        {
            AnalyticsUtil.AuthentificationClickedLoginButton();

            base.Execute(formid, fields, data);
        }
Beispiel #29
0
        /// <summary>
        /// Adds CustomerInfo, Shippingdetails and Billingdetails into the ShoppingCart instance
        /// Also updates the CustomerInfo session
        /// </summary>
        /// <param name="formid">The formid.</param>
        /// <param name="fields">The fields.</param>
        /// <param name="data">The data.</param>
        /// <exception cref="ValidatorException">Throws <c>ValidatorException</c> in a customer is already exists.</exception>
        public void Execute(ID formid, AdaptedResultList fields, params object[] data)
        {
            AnalyticsUtil.CheckoutNext();

            NameValueCollection orderInfo = new NameValueCollection();

            ActionHelper.FillFormData(orderInfo, fields, this.FillOrderInfo);
            bool isNewUser = false;
            ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();
            CustomerInfo customerInfo;

            if (orderInfo["HideCreateUserSection"] == "1" && !string.IsNullOrEmpty(orderInfo["Password"]) && !Sitecore.Context.User.IsAuthenticated)
            {
                try
                {
                    string fullNickName = Sitecore.Context.Domain.GetFullName(orderInfo["Email"]);
                    customerInfo = customerManager.CreateCustomerAccount(fullNickName, orderInfo["Password"], orderInfo["Email"]);
                }
                catch (MembershipCreateUserException ex)
                {
                    Log.Error("Unable to create a customer account.", ex, this);
                    throw new ValidatorException(ex.Message, ex);
                }

                isNewUser = true;
            }
            else
            {
                customerInfo = customerManager.CurrentUser;
            }

            Assert.IsNotNull(customerInfo, "Cannot create user");

            foreach (string key in orderInfo.AllKeys)
            {
                customerInfo[key] = orderInfo[key];
            }

            customerInfo.BillingAddress.Name    = orderInfo["Name"];
            customerInfo.BillingAddress.Address = orderInfo["Address"];
            customerInfo.BillingAddress.Zip     = orderInfo["Zip"];
            customerInfo.BillingAddress.City    = orderInfo["City"];
            customerInfo.BillingAddress.State   = orderInfo["State"];
            customerInfo.Email = orderInfo["Email"];

            // Find country.
            if (!string.IsNullOrEmpty(orderInfo["Country"]))
            {
                IEntityProvider <Country> countryProvider = Context.Entity.Resolve <IEntityProvider <Country> >();
                customerInfo.BillingAddress.Country = countryProvider.Get(orderInfo["Country"]);
            }

            // If shipping checkbox is checked
            if (orderInfo["HideThisSection"] == "1")
            {
                customerInfo.ShippingAddress.Name    = orderInfo["ShippingName"];
                customerInfo.ShippingAddress.Address = orderInfo["ShippingAddress"];
                customerInfo.ShippingAddress.Zip     = orderInfo["ShippingZip"];
                customerInfo.ShippingAddress.City    = orderInfo["ShippingCity"];
                customerInfo.ShippingAddress.State   = orderInfo["ShippingState"];

                if (!string.IsNullOrEmpty(orderInfo["ShippingCountry"]))
                {
                    IEntityProvider <Country> countryProvider = Context.Entity.Resolve <IEntityProvider <Country> >();
                    customerInfo.ShippingAddress.Country = countryProvider.Get(orderInfo["ShippingCountry"]);
                }
            }
            else
            {
                EntityHelper entityHepler      = Context.Entity.Resolve <EntityHelper>();
                AddressInfo  targetAddressInfo = customerInfo.ShippingAddress;

                entityHepler.CopyPropertiesValues(customerInfo.BillingAddress, ref targetAddressInfo);
            }

            ShoppingCart shoppingCart = Context.Entity.GetInstance <ShoppingCart>();

            shoppingCart.CustomerInfo = customerInfo;

            IEntityProvider <NotificationOption> notificationProvider = Context.Entity.Resolve <IEntityProvider <NotificationOption> >();

            Assert.IsNotNull(notificationProvider, "Notification options provider is null");

            shoppingCart.NotificationOption      = notificationProvider.Get("Email");
            shoppingCart.NotificationOptionValue = orderInfo["Email"];

            if (isNewUser)
            {
                customerManager.UpdateCustomerProfile(customerInfo);
            }

            customerManager.CurrentUser = customerInfo;
            Context.Entity.SetInstance(shoppingCart);

            // Indicates that the form has been filled out and that it should be initialized if the user returnes to this page.
            ICheckOut checkOut = Context.Entity.GetInstance <ICheckOut>();

            if (checkOut is CheckOut)
            {
                ((CheckOut)checkOut).HasOtherShippingAddressBeenChecked = orderInfo["HideThisSection"] == "1";
            }

            Context.Entity.SetInstance(checkOut);

            ItemUtil.RedirectToNavigationLink(NavigationLinkNext, false);
        }