private void rptCartItems_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (cart == null)
            {
                return;
            }
            if (store == null)
            {
                return;
            }

            string strGuid = e.CommandArgument.ToString();

            if (strGuid.Length != 36)
            {
                return;
            }

            Guid itemGuid = new Guid(strGuid);

            switch (e.CommandName)
            {
            case "updateQuantity":

                int     quantity = 1;
                TextBox txtQty   = e.Item.FindControl("txtQuantity") as TextBox;
                if (txtQty != null)
                {
                    try
                    {
                        int.TryParse(txtQty.Text, NumberStyles.Integer, CultureInfo.InvariantCulture, out quantity);
                    }
                    catch (ArgumentException) { }
                }
                cart.UpdateCartItemQuantity(itemGuid, quantity);

                break;

            case "delete":

                cart.DeleteItem(itemGuid);
                cart.ResetCartOffers();
                cart.RefreshTotals();
                cart.Save();

                break;
            }

            StoreHelper.EnsureValidDiscounts(store, cart);

            WebUtils.SetupRedirect(this, Request.RawUrl);
        }
Пример #2
0
        private void LoadSettings()
        {
            store = StoreHelper.GetStore();

            if (store == null)
            {
                return;
            }

            commerceConfig  = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            if (Request.IsAuthenticated)
            {
                siteUser = SiteUtils.GetCurrentSiteUser();
            }

            if (StoreHelper.UserHasCartCookie(store.Guid))
            {
                cart = StoreHelper.GetCart();

                if (cart != null)
                {
                    cartOffers = cart.GetOffers();
                    canCheckoutWithoutAuthentication = store.CanCheckoutWithoutAuthentication(cart);

                    if (cart.LastModified < DateTime.UtcNow.AddDays(-1) && cart.DiscountCodesCsv.Length > 0)
                    {
                        StoreHelper.EnsureValidDiscounts(store, cart);
                    }

                    if (cart.UserGuid == Guid.Empty && siteUser != null)
                    {
                        cart.UserGuid = siteUser.UserGuid;
                        cart.Save();
                    }

                    cart.RefreshTotals();
                }
            }

            ConfigureCheckoutButtons();
            AddClassToBody("webstore webstorecheckout");
        }
Пример #3
0
        private void LoadSettings()
        {
            AddClassToBody("webstore webstorecart");

            SiteUtils.AddNoIndexMeta(Page);

            commerceConfig  = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            if (moduleSettings != null)
            {
                config = new WebStoreConfiguration(moduleSettings);
            }

            litCartFooter.Text = config.CartPageFooter;

            if (Request.IsAuthenticated)
            {
                siteUser = SiteUtils.GetCurrentSiteUser();
            }

            store = StoreHelper.GetStore();
            if (store == null)
            {
                return;
            }

            if (
                (StoreHelper.UserHasCartCookie(store.Guid)) ||
                (Request.IsAuthenticated)
                )
            {
                cart = StoreHelper.GetCart();
            }

            //if we can't process cards internally there is no reason (except a free order) to go to the ConfirmOrder.aspx page
            //and the order can be processed wtithout the user signing in or if the user is already signed in
            if (
                ((!commerceConfig.CanProcessStandardCards) && (commerceConfig.WorldPayInstallationId.Length == 0)) &&
                ((Request.IsAuthenticated) || (canCheckoutWithoutAuthentication))
                )
            {
                lnkCheckout.Visible = false;
            }

            if (cart == null)
            {
                pnlDiscountCode.Visible = false;
                lnkCheckout.Visible     = false;
                return;
            }

            if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0))
            {
                StoreHelper.EnsureValidDiscounts(store, cart);
            }

            if (store != null)
            {
                canCheckoutWithoutAuthentication = store.CanCheckoutWithoutAuthentication(cart);
            }

            cartList.Store           = store;
            cartList.ShoppingCart    = cart;
            cartList.CurrencyCulture = currencyCulture;

            cartListAlt.Store           = store;
            cartListAlt.ShoppingCart    = cart;
            cartListAlt.CurrencyCulture = currencyCulture;

            if (displaySettings.UseAltCartList)
            {
                cartList.Visible    = false;
                cartListAlt.Visible = true;
            }


            // disable till I finish
            //canCheckoutWithoutAuthentication = false;

            ConfigureCheckoutButtons();

            int countOfDiscountCodes = Discount.GetCountOfActiveDiscountCodes(store.ModuleGuid);

            pnlDiscountCode.Visible = (countOfDiscountCodes > 0);

            // don't show the discount code panel if the cart is empty
            if (cart.SubTotal == 0)
            {
                // allow checkout if cart has items (support checkout with free items)
                if (cart.CartOffers.Count == 0)
                {
                    lnkCheckout.Visible = false;
                }
                else
                {
                    //cart has free items
                    lnkCheckout.Visible = true;
                }
                //litOr.Visible = false;
                //btnPayPal.Visible = false;
                //btnGoogleCheckout.Visible = false;
                pnlDiscountCode.Visible = false;
            }

            // kill switch to disable discount codes (doesn't prevent use of ones already in the cart but prevents new uses
            bool disableDiscounts = false;

            ConfigHelper.GetBoolProperty("WebStoreDisabledDiscounts", disableDiscounts);
            if (disableDiscounts)
            {
                pnlDiscountCode.Visible = false;
            }



            //if (!Page.IsPostBack)
            //{
            //    if ((commerceConfig.PayPalIsEnabled) && (commerceConfig.PayPalUsePayPalStandard))
            //    {
            //        if (Request.IsAuthenticated)
            //        {
            //            siteUser = SiteUtils.GetCurrentSiteUser();
            //            SetupPayPalStandardForm();
            //        }
            //        else
            //        {
            //            //TODO: if the cart has no download items allow checkout without registration/sign in

            //            // we need the user to be signed in before we send them to paypal if using PayPal Standard
            //            // because we want to return them to their order summary and that requires login
            //            // so we need to know who the user is before sending them to PayPal
            //            litOr.Visible = false;
            //            btnPayPal.Visible = false;
            //            btnGoogleCheckout.Visible = false;
            //        }
            //    }
            //}



            //if (!Request.IsAuthenticated)
            //{


            //    if (commerceConfig.GoogleCheckoutIsEnabled)
            //    {
            //        if (
            //        (!commerceConfig.Is503TaxExempt)
            //        && (cart != null)
            //        && (cart.HasDonations())
            //        )
            //        {
            //            lblGoogleMessage.Text = WebStoreResources.GoogleCheckoutDisabledForDonationsMessage;
            //            lblGoogleMessage.Visible = true;
            //            PaymentAcceptanceMark mark = (PaymentAcceptanceMark)pam1;
            //            mark.SuppressGoogleCheckout = true;

            //            btnGoogleCheckout.Visible = true;
            //            btnGoogleCheckout.Enabled = false;
            //        }
            //    }
            //}
            //else
            //{
            //    if (
            //        (!commerceConfig.Is503TaxExempt)
            //        && (cart != null)
            //        && (cart.HasDonations())
            //        && (commerceConfig.GoogleCheckoutIsEnabled)
            //        )
            //    {
            //        btnGoogleCheckout.Visible = true;
            //        btnGoogleCheckout.Enabled = false;
            //        lblGoogleMessage.Text = WebStoreResources.GoogleCheckoutDisabledForDonationsMessage;
            //        lblGoogleMessage.Visible = true;
            //    }


            //}
        }
        private void LoadSettings()
        {
            PageId   = WebUtils.ParseInt32FromQueryString("pageid", -1);
            ModuleId = WebUtils.ParseInt32FromQueryString("mid", -1);
            payPalGetExpressCheckoutLogGuid = WebUtils.ParseGuidFromQueryString("plog", payPalGetExpressCheckoutLogGuid);

            if (payPalGetExpressCheckoutLogGuid == Guid.Empty)
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }

            checkoutDetailsLog = new PayPalLog(payPalGetExpressCheckoutLogGuid);

            if (checkoutDetailsLog.RowGuid == Guid.Empty)
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }

            cart = (Cart)SerializationHelper.DeserializeFromString(typeof(Cart), checkoutDetailsLog.SerializedObject);

            if (cart == null)
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }
            cart.DeSerializeCartOffers();

            cart.RefreshTotals();


            if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0))
            {
                StoreHelper.EnsureValidDiscounts(store, cart);
            }


            siteUser = SiteUtils.GetCurrentSiteUser();
            //if (siteUser == null)
            //{
            //    Response.Redirect(SiteUtils.GetCurrentPageUrl());
            //}

            if ((siteUser != null) && (cart.UserGuid == Guid.Empty))
            {
                // user wasn't logged in when express checkout was called
                cart.UserGuid = siteUser.UserGuid;
                cart.Save();
                //if (checkoutDetailsLog.UserGuid == Guid.Empty)
                //{
                //    // we need to make sure we have the user in the log and serialized cart
                //    checkoutDetailsLog.UserGuid = siteUser.UserGuid;
                //    cart.SerializeCartOffers();
                //    checkoutDetailsLog.SerializedObject = SerializationHelper.SerializeToSoap(cart);
                //    checkoutDetailsLog.Save();

                //}
            }

            if ((siteUser != null) && (cart.UserGuid != siteUser.UserGuid))
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }



            if (ModuleId == -1)
            {
                ModuleId = StoreHelper.FindStoreModuleId(CurrentPage);
            }


            store = StoreHelper.GetStore();


            commerceConfig  = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            if (siteUser != null)
            {
                pnlRequireLogin.Visible = false;
            }
            else
            {
                btnMakePayment.Visible = false;
            }

            AddClassToBody("webstore webstoreexpresscheckout");
        }
Пример #5
0
        private void LoadSettings()
        {
            store = StoreHelper.GetStore();
            if (store == null)
            {
                return;
            }

            commerceConfig  = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);
            storeCountry    = new GeoCountry(siteSettings.DefaultCountryGuid);

            if (Request.IsAuthenticated)
            {
                siteUser = SiteUtils.GetCurrentSiteUser();
            }

            if (StoreHelper.UserHasCartCookie(store.Guid))
            {
                cart = StoreHelper.GetCart();

                if (cart != null)
                {
                    if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0))
                    {
                        StoreHelper.EnsureValidDiscounts(store, cart);
                    }

                    if (siteUser != null)
                    {
                        if (cart.UserGuid == Guid.Empty)
                        {
                            // take ownership of anonymous cart
                            cart.UserGuid = siteUser.UserGuid;
                            cart.Save();
                            StoreHelper.InitializeOrderInfo(cart, siteUser);
                        }
                        else
                        {
                            // cart already has a user guid but
                            // check if it matches the current user
                            // cart cookie could have been left behind by a previous user
                            // on shared computers
                            // if cart user guid doesn't match reset billing shipping info
                            // and any other identifiers
                            // but leave items in cart
                            if (cart.UserGuid != siteUser.UserGuid)
                            {
                                cart.ResetUserInfo();
                                cart.UserGuid = siteUser.UserGuid;
                                cart.Save();
                                StoreHelper.InitializeOrderInfo(cart, siteUser);
                            }
                        }
                    }

                    if (WebStoreConfiguration.IsDemo)
                    {
                        LoadDemoCustomer();
                    }


                    canCheckoutWithoutAuthentication = store.CanCheckoutWithoutAuthentication(cart);


                    // disable till I finish
                    //canCheckoutWithoutAuthentication = false;
                }

                AddClassToBody("webstore webstoreconfirmorder");
            }


            pnlRequireLogin.Visible = !Request.IsAuthenticated;

            if ((canCheckoutWithoutAuthentication) || (Request.IsAuthenticated))
            {
                pnlOrderDetail.Visible   = commerceConfig.CanProcessStandardCards || (commerceConfig.WorldPayInstallationId.Length > 0);
                pnlRequireLogin.Visible  = true;
                pnlShippingTotal.Visible = false;
                pnlTaxTotal.Visible      = false;
                pnlOrderTotal.Visible    = false;
            }

            if ((cart != null) && (cart.SubTotal == 0) && (cart.CartOffers.Count > 0))
            {
                // free checkout
                pnlOrderDetail.Visible = true;
            }

            if (pnlOrderDetail.Visible)
            {
                tblCountryList = GeoCountry.GetList();
            }


            ConfigureCheckoutButtons();

            //if (!Page.IsPostBack)
            //{
            //    if ((commerceConfig.PayPalIsEnabled) && (commerceConfig.PayPalUsePayPalStandard))
            //    {
            //        if (Request.IsAuthenticated)
            //        {
            //            SetupPayPalStandardForm();
            //        }
            //        else
            //        {
            //            // we need the user to be signed in before we send them to paypal if using PayPal Standard
            //            // because we want to return them to their order summary and that requires login
            //            // so we need to know who the user is before sending them to PayPal
            //            litOr.Visible = false;
            //            btnPayPal.Visible = false;
            //            btnGoogleCheckout.Visible = false;
            //        }
            //    }
            //}

            //if (!Request.IsAuthenticated)
            //{

            //    pnlOrderDetail.Visible = false;
            //    pnlRequireLogin.Visible = true;
            //    pnlShippingTotal.Visible = false;
            //    pnlTaxTotal.Visible = false;
            //    pnlOrderTotal.Visible = false;

            //    if (commerceConfig.GoogleCheckoutIsEnabled)
            //    {
            //        if (
            //        (!commerceConfig.Is503TaxExempt)
            //        && ((cart != null) && (cart.HasDonations()))
            //        )
            //        {
            //            //btnGoogleCheckout.Visible = false;
            //            lblGoogleMessage.Text = WebStoreResources.GoogleCheckoutDisabledForDonationsMessage;
            //            lblGoogleMessage.Visible = true;
            //            PaymentAcceptanceMark mark = (PaymentAcceptanceMark)pam1;
            //            mark.SuppressGoogleCheckout = true;

            //            mark = (PaymentAcceptanceMark)PaymentAcceptanceMark1;
            //            mark.SuppressGoogleCheckout = true;

            //            btnGoogleCheckout.Visible = true;
            //            btnGoogleCheckout.Enabled = false;
            //        }
            //    }

            //}
            //else
            //{
            //    if (
            //        (!commerceConfig.Is503TaxExempt)
            //         && ((cart != null)&& (cart.HasDonations()))
            //        && (commerceConfig.GoogleCheckoutIsEnabled)
            //        )
            //    {
            //        btnGoogleCheckout.Visible = true;
            //        btnGoogleCheckout.Enabled = false;
            //        lblGoogleMessage.Text = WebStoreResources.GoogleCheckoutDisabledForDonationsMessage;
            //        lblGoogleMessage.Visible = true;
            //    }


            //}
        }
Пример #6
0
        private void LoadSettings()
        {
            AddClassToBody($"webstore webstorecart {displaySettings.AdditionalBodyClass}");

            SiteUtils.AddNoIndexMeta(Page);

            commerceConfig  = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            if (moduleSettings != null)
            {
                config = new WebStoreConfiguration(moduleSettings);
            }

            litCartFooter.Text = config.CartPageFooter;

            if (Request.IsAuthenticated)
            {
                siteUser = SiteUtils.GetCurrentSiteUser();
            }

            store = StoreHelper.GetStore();
            if (store == null)
            {
                return;
            }

            if (
                (StoreHelper.UserHasCartCookie(store.Guid)) ||
                (Request.IsAuthenticated)
                )
            {
                cart = StoreHelper.GetCart();
            }

            //if we can't process cards internally there is no reason (except a free order) to go to the ConfirmOrder.aspx page
            //and the order can be processed wtithout the user signing in or if the user is already signed in
            if (
                ((!commerceConfig.CanProcessStandardCards) && (commerceConfig.WorldPayInstallationId.Length == 0))
                //&& ((Request.IsAuthenticated) || (canCheckoutWithoutAuthentication)) //moved login prompt to cart so we don't need to have a link to the confirmorder page
                )
            {
                //lnkConfirmOrder.Visible = false;
                litConfirmOrder.Visible = false;
            }

            if (cart == null)
            {
                pnlDiscountCode.Visible = false;
                //lnkConfirmOrder.Visible = false;
                litConfirmOrder.Visible = false;
                return;
            }

            if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0))
            {
                StoreHelper.EnsureValidDiscounts(store, cart);
            }

            if (store != null)
            {
                canCheckoutWithoutAuthentication = store.CanCheckoutWithoutAuthentication(cart);
            }

            cartList.Store           = store;
            cartList.ShoppingCart    = cart;
            cartList.CurrencyCulture = currencyCulture;
            cartList.DisplaySettings = displaySettings;

            cartListAlt.Store           = store;
            cartListAlt.ShoppingCart    = cart;
            cartListAlt.CurrencyCulture = currencyCulture;

            if (displaySettings.UseAltCartList)
            {
                cartList.Visible    = false;
                cartListAlt.Visible = true;
            }

            ConfigureCheckoutButtons();

            int countOfDiscountCodes = Discount.GetCountOfActiveDiscountCodes(store.ModuleGuid);

            pnlDiscountCode.Visible = (countOfDiscountCodes > 0);

            // don't show the discount code panel if the cart is empty
            if (cart.SubTotal == 0)
            {
                // allow checkout if cart has items (support checkout with free items)
                if (cart.CartOffers.Count == 0)
                {
                    //lnkConfirmOrder.Visible = false;
                    litConfirmOrder.Visible = false;
                }
                else
                {
                    //cart has free items
                    //lnkConfirmOrder.Visible = true;
                }
                //litOr.Visible = false;
                //btnPayPal.Visible = false;
                pnlDiscountCode.Visible = false;
            }

            // kill switch to disable discount codes (doesn't prevent use of ones already in the cart but prevents new uses
            bool disableDiscounts = false;

            ConfigHelper.GetBoolProperty("WebStoreDisabledDiscounts", disableDiscounts);
            if (disableDiscounts)
            {
                pnlDiscountCode.Visible = false;
            }
        }