Пример #1
0
        void rptOffers_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "addToCart":
            default:

                Cart cart = StoreHelper.GetCart();
                if (cart == null)
                {
                    return;
                }

                string strGuid = e.CommandArgument.ToString();
                if (strGuid.Length != 36)
                {
                    return;
                }

                Guid  offerGuid = new Guid(strGuid);
                Offer offer     = new Offer(offerGuid);

                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) { }
                }
                if (quantity < 0)
                {
                    quantity = 1;
                }

                if (cart.AddOfferToCart(offer, quantity))
                {
                    // redirect to cart page
                    WebUtils.SetupRedirect(this, SiteRoot +
                                           "/WebStore/Cart.aspx?pageid="
                                           + pageId.ToString()
                                           + "&mid=" + moduleId.ToString()
                                           + "&cart=" + cart.CartGuid.ToString());

                    return;
                }

                WebUtils.SetupRedirect(this, Request.RawUrl);

                break;
            }
        }
Пример #2
0
        private void AddToCart()
        {
            if (offerGuid != Guid.Empty)
            {
                Offer offer = new Offer(offerGuid);
                //int quantity = 1;
                qtyOrdered = WebUtils.ParseInt32FromQueryString("qty", qtyOrdered);

                if (!offer.IsAvailable)
                {
                    WebUtils.SetupRedirect(this, Page.ResolveUrl(
                                               "~/WebStore/OfferDetail.aspx?pageid="
                                               + pageId.ToString()
                                               + "&mid=" + moduleId.ToString()
                                               + "&offer=" + offerGuid.ToString()));

                    return;
                }



                if (
                    (offer.Guid == offerGuid) &&
                    (offer.StoreGuid == store.Guid) &&
                    (store.Guid != Guid.Empty)
                    )
                {
                    //Cart cart = StoreHelper.GetCart(store.Guid);
                    Cart cart = StoreHelper.GetCart();

                    if (cart != null)
                    {
                        if (cart.AddOfferToCart(offer, qtyOrdered))
                        {
                            // redirect to cart page
                            WebUtils.SetupRedirect(this,
                                                   SiteRoot + "/WebStore/Cart.aspx?pageid="
                                                   + pageId.ToString()
                                                   + "&mid=" + moduleId.ToString()
                                                   + "&cart=" + cart.CartGuid.ToString());

                            return;
                        }
                    }
                }
            }
        }
Пример #3
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");
        }
Пример #4
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;
            //    }


            //}
        }
Пример #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;
            }
        }