示例#1
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;
            //    }

            //}
        }
示例#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;
            //    }

            //}
        }