Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            HccApp.CurrentStore.Settings.Analytics.UseGoogleAdWords     = chkGoogleAdwords.Checked;
            HccApp.CurrentStore.Settings.Analytics.GoogleAdWordsId      = GoogleAdwordsConversionIdField.Text;
            HccApp.CurrentStore.Settings.Analytics.GoogleAdWordsFormat  = ddlAdwordsFormat.SelectedValue;
            HccApp.CurrentStore.Settings.Analytics.GoogleAdWordsLabel   = GoogleAdwordsLabelField.Text;
            HccApp.CurrentStore.Settings.Analytics.GoogleAdWordsBgColor = GoogleAdwordsBackgroundColorField.Text;

            HccApp.CurrentStore.Settings.Analytics.UseGoogleEcommerce       = chkGoogleEcommerce.Checked;
            HccApp.CurrentStore.Settings.Analytics.GoogleEcommerceCategory  = GoogleEcommerceCategoryNameField.Text;
            HccApp.CurrentStore.Settings.Analytics.GoogleEcommerceStoreName = GoogleEcommerceStoreNameField.Text;

            var googleSettings = new GoogleAnalyticsSettings();

            googleSettings.UseTracker = chkGoogleTracker.Checked;
            googleSettings.TrackerId  = GoogleTrackingIdField.Text;
            HccApp.AccountServices.SetGoogleAnalyticsSettings(googleSettings);

            HccApp.CurrentStore.Settings.Analytics.UseYahooTracker = chkYahoo.Checked;
            HccApp.CurrentStore.Settings.Analytics.YahooAccountId  = YahooAccountIdField.Text;

            HccApp.CurrentStore.Settings.Analytics.AdditionalMetaTags = AdditionalMetaTagsField.Text;
            HccApp.CurrentStore.Settings.Analytics.BottomAnalytics    = BottomAnalyticsField.Text;

            HccApp.CurrentStore.Settings.Analytics.UseShopZillaSurvey = chkUseShopZillaSurvey.Checked;
            HccApp.CurrentStore.Settings.Analytics.ShopZillaId        = ShopZillaIdField.Text.Trim();

            HccApp.UpdateCurrentStore();

            ucMessageBox.ShowOk(Localization.GetString("SettingsSuccessful"));
        }
        private void SaveInfoToOrder(bool savePaymentData)
        {
            if (chkBillToSame.Checked)
            {
                BillToAddress.LoadFromAddress(ShipToAddress.GetAsAddress());
            }

            // Save Information to Cart in Case Save as Order Fails
            CurrentOrder.BillingAddress  = BillToAddress.GetAsAddress();
            CurrentOrder.ShippingAddress = ShipToAddress.GetAsAddress();
            TagOrderWithUser();

            CurrentOrder.UserEmail    = EmailAddressTextBox.Text;
            CurrentOrder.Instructions = txtInstructions.Text.Trim();

            // Save Shipping Selection
            var r = FindSelectedRate(ShippingRatesList.SelectedValue, CurrentOrder);

            if (r != null)
            {
                HccApp.OrderServices.OrdersRequestShippingMethodByUniqueKey(r.UniqueKey, CurrentOrder);
            }

            if (savePaymentData)
            {
                // Save Payment Information
                SavePaymentInfo();
            }

            HccApp.CalculateOrderAndSave(CurrentOrder);
        }
Exemplo n.º 3
0
        private OrderPackage ShipItems(Commerce.Orders.Order o, string trackingNumber, string serviceProvider,
                                       string serviceCode)
        {
            var p = new OrderPackage
            {
                ShipDateUtc                 = DateTime.UtcNow,
                TrackingNumber              = trackingNumber,
                ShippingProviderId          = serviceProvider,
                ShippingProviderServiceCode = serviceCode
            };

            foreach (var li in o.Items)
            {
                if (li != null)
                {
                    var qty = li.Quantity;
                    p.Items.Add(new OrderPackageItem(li.ProductId, li.Id, qty));
                    p.Weight += li.ProductShippingWeight * qty;
                }
            }

            p.WeightUnits = WebAppSettings.ApplicationWeightUnits;
            o.Packages.Add(p);

            HccApp.OrdersShipPackage(p, o);
            o.EvaluateCurrentShippingStatus();
            HccApp.OrderServices.Orders.Update(o);

            return(p);
        }
Exemplo n.º 4
0
        protected void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var gridView = sender as GridView;
            var Id       = (long)gridView.DataKeys[e.RowIndex].Value;

            var lineItem = CurrentOrder.Items.SingleOrDefault(y => y.Id == Id);

            if (lineItem != null)
            {
                // Before removing lineitem try to cancel subscription
                if (CurrentOrder.IsRecurring && !lineItem.RecurringBilling.IsCancelled)
                {
                    var payManager = new OrderPaymentManager(CurrentOrder, HccApp);
                    var res        = payManager.RecurringSubscriptionCancel(lineItem.Id);
                }

                lineItem.QuantityReserved = lineItem.Quantity;
                HccApp.CatalogServices.InventoryLineItemUnreserveInventory(lineItem);

                CurrentOrder.Items.Remove(lineItem);

                HccApp.CalculateOrder(CurrentOrder);
                HccApp.OrderServices.EvaluatePaymentStatus(CurrentOrder);
                HccApp.OrderServices.Orders.Update(CurrentOrder);
            }

            var handler = OrderEdited;

            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }
        }
Exemplo n.º 5
0
        public ActionResult AddToCart(long itemid)
        {
            var customerId = HccApp.CurrentCustomerId;
            var wi         = HccApp.CatalogServices.WishListItems.Find(itemid);

            if (wi == null || wi.CustomerId != customerId)
            {
                return(Redirect(Url.RouteHccUrl(HccRoute.WishList)));
            }

            // Add to Cart
            var p = HccApp.CatalogServices.Products.FindWithCache(wi.ProductId);

            var isPurchasable       = ValidateSelections(p, wi.SelectionData);
            var isNotRecurringMixed = ValidateRecurringItems(p);

            if (isPurchasable && isNotRecurringMixed)
            {
                var li = p.ConvertToLineItem(HccApp, 1, wi.SelectionData);

                HccApp.OrderServices.EnsureShoppingCart();
                HccApp.AddToOrderWithCalculateAndSave(CurrentCart, li);

                return(Redirect(Url.RouteHccUrl(HccRoute.Cart)));
            }
            var items = HccApp.CatalogServices.WishListItems.FindByCustomerIdPaged(HccApp.CurrentCustomerId, 1, 50);
            var model = PrepItems(items);

            if (model.Count < 1)
            {
                FlashInfo(Localization.GetString("WishListEmpty"));
            }
            return(View("Index", model));
        }
Exemplo n.º 6
0
        public ActionResult UpdateLineItem()
        {
            var lineItemId = long.Parse(Request["lineitemid"]);

            var lineItem = CurrentCart.Items.SingleOrDefault(li => li.Id == lineItemId);

            if (lineItem != null)
            {
                var product = lineItem.GetAssociatedProduct(HccApp);
                if (product != null)
                {
                    var minQuantity = Math.Max(lineItem.FreeQuantity, Math.Max(product.MinimumQty, 1));
                    var quantity    = 0;
                    if (int.TryParse(Request["lineitemquantity"], out quantity))
                    {
                        if (quantity >= minQuantity)
                        {
                            lineItem.Quantity = quantity;

                            HccApp.CalculateOrderAndSave(CurrentCart);
                        }
                    }
                }
            }
            return(Redirect(Url.RouteHccUrl(HccRoute.Cart)));
        }
Exemplo n.º 7
0
 private void LoadImagePreview(Product p)
 {
     ucImageUploadLarge.ImageUrl = DiskStorage.ProductImageUrlMedium(HccApp, p.Bvin, p.ImageFileMedium,
                                                                     HccApp.IsCurrentRequestSecure());
     imgPreviewSmall.ImageUrl = DiskStorage.ProductImageUrlSmall(HccApp, p.Bvin, p.ImageFileSmall,
                                                                 HccApp.IsCurrentRequestSecure());
 }
Exemplo n.º 8
0
        private SystemOperationResult InventoryCheck(ProductPageViewModel model)
        {
            var data = HccApp.CatalogServices.InventoryCheck(model.LocalProduct, model.Selections);

            model.StockMessage       = data.InventoryMessage;
            model.IsAvailableForSale = data.IsAvailableForSale;

            var formQuantity = Request.Form["qty"];

            if (model.LocalProduct.IsUserSuppliedPrice)
            {
                formQuantity = "1";
            }

            if (!string.IsNullOrEmpty(formQuantity))
            {
                formQuantity = security.InputFilter(formQuantity.Trim(), PortalSecurity.FilterFlag.NoMarkup);
            }

            var qty = 0;

            if (int.TryParse(formQuantity, out qty))
            {
                var li = ConvertProductToLineItem(model);
                li.Quantity = Convert.ToInt16(formQuantity);
                return(HccApp.CheckForStockOnItems(li));
            }
            return(new SystemOperationResult(false, Localization.GetString("EnterProperQty")));
        }
Exemplo n.º 9
0
        public ActionResult AjaxSignIn()
        {
            var username = Request.Form["username"] ?? string.Empty;
            var password = Request.Form["password"] ?? string.Empty;

            var    validated    = new ValidateModelResponse();
            var    errorMessage = string.Empty;
            string userId       = null;

            if (HccApp.MembershipServices.LoginUser(username, password, out errorMessage, out userId))
            {
                if (CurrentCart != null)
                {
                    var custAcc = HccApp.MembershipServices.Customers.Find(userId);
                    CurrentCart.UserEmail = custAcc != null?custAcc.Email.Trim() : null;

                    CurrentCart.UserID = userId;
                    HccApp.CalculateOrderAndSave(CurrentCart);
                }

                validated.Success = true;
            }
            else
            {
                validated.ResultMessages.Add(errorMessage);
                validated.Success = false;
            }

            return(new PreJsonResult(Web.Json.ObjectToJson(validated)));
        }
Exemplo n.º 10
0
        private void SaveData()
        {
            HccApp.CurrentStore.Settings.MailServer.HostAddress       = MailServerField.Text.Trim();
            HccApp.CurrentStore.Settings.MailServer.UseAuthentication = chkMailServerAuthentication.Checked;
            HccApp.CurrentStore.Settings.MailServer.Username          = UsernameField.Text.Trim();
            if (PasswordField.Text.Trim().Length > 0)
            {
                if (PasswordField.Text != "****************")
                {
                    HccApp.CurrentStore.Settings.MailServer.Password = PasswordField.Text.Trim();
                    PasswordField.Text = "****************";
                }
            }

            HccApp.CurrentStore.Settings.MailServer.UseSsl = chkSSL.Checked;
            HccApp.CurrentStore.Settings.MailServer.Port   = SmtpPortField.Text.Trim();
            if (lstMailServerChoice.SelectedItem.Value == "1")
            {
                HccApp.CurrentStore.Settings.MailServer.UseCustomMailServer = true;
            }
            else
            {
                HccApp.CurrentStore.Settings.MailServer.UseCustomMailServer = false;
            }
            HccApp.UpdateCurrentStore();
        }
        /// <summary>
        ///     Allows for the REST API to delete a product from the store
        /// </summary>
        /// <param name="parameters">
        ///     Parameters passed in the URL of the REST API call. A single parameter (product ID/bvin) is
        ///     expected.
        /// </param>
        /// <param name="querystring">Name/value pairs from the REST API call querystring. Not used in this method.</param>
        /// <param name="postdata">This parameter is not used in this method</param>
        /// <returns>
        ///     String - a JSON representation of the Errors/Content to return. Content will contain either True or False,
        ///     depending on success of the deletion
        /// </returns>
        public override string DeleteAction(string parameters, NameValueCollection querystring, string postdata)
        {
            var data = string.Empty;
            var bvin = FirstParameter(parameters);


            if (bvin == string.Empty)
            {
                var howManyString = querystring["howmany"];
                var howMany       = 0;
                int.TryParse(howManyString, out howMany);

                // Clear All Products Requested
                var response = new ApiResponse <ClearProductsData> {
                    Content = HccApp.ClearProducts(howMany)
                };
                data = Json.ObjectToJson(response);
            }
            else
            {
                // Single Item Delete
                var response = new ApiResponse <bool>
                {
                    Content = HccApp.CatalogServices.DestroyProduct(bvin, HccApp.CurrentStore.Id)
                };
                data = Json.ObjectToJson(response);
            }

            return(data);
        }
Exemplo n.º 12
0
        private OrderPackage ShipItems(Order order, string trackingNumber, string serviceProvider, string serviceCode,
                                       bool dontShip, string shippingMethodId = null)
        {
            var p = new OrderPackage
            {
                ShipDateUtc                 = DateTime.UtcNow,
                TrackingNumber              = trackingNumber,
                ShippingProviderId          = serviceProvider,
                ShippingProviderServiceCode = serviceCode,
                OrderId          = order.bvin,
                ShippingMethodId = string.IsNullOrEmpty(shippingMethodId) == false ? shippingMethodId : string.Empty
            };

            foreach (GridViewRow gvr in ItemsGridView.Rows)
            {
                if (gvr.RowType == DataControlRowType.DataRow)
                {
                    var lineItemId = (long)ItemsGridView.DataKeys[gvr.RowIndex].Value;
                    var lineItem   = order.GetLineItem(lineItemId);
                    if (lineItem == null || lineItem.IsNonShipping)
                    {
                        continue;
                    }

                    var qty       = 0;
                    var QtyToShip = (TextBox)gvr.FindControl("QtyToShip");
                    if (QtyToShip != null)
                    {
                        if (!int.TryParse(QtyToShip.Text, out qty))
                        {
                            qty = 0;
                        }
                    }

                    // Prevent shipping more than ordered if order is not recurring
                    if (!order.IsRecurring && qty > lineItem.Quantity - lineItem.QuantityShipped)
                    {
                        qty = lineItem.Quantity - lineItem.QuantityShipped;
                    }

                    if (qty > 0)
                    {
                        p.Items.Add(new OrderPackageItem(lineItem.ProductId, lineItem.Id, qty));
                        p.Weight += lineItem.ProductShippingWeight * qty;
                    }
                }
            }
            p.WeightUnits = WebAppSettings.ApplicationWeightUnits;

            if (p.Items.Count > 0)
            {
                order.Packages.Add(p);
                if (!dontShip)
                {
                    HccApp.OrdersShipPackage(p, order);
                }
                HccApp.OrderServices.Orders.Update(order);
            }
            return(p);
        }
Exemplo n.º 13
0
        private bool Save()
        {
            var result = false;

            HccApp.CurrentStore.Settings.UseLogoImage = chkUseLogoImage.Checked;
            HccApp.CurrentStore.Settings.FriendlyName = txtSiteName.Text.Trim();
            HccApp.CurrentStore.Settings.LogoText     = txtLogoText.Text.Trim();

            result = true;

            if (!string.IsNullOrEmpty(ucStoreLogo.FileName))
            {
                var fileName = Path.GetFileNameWithoutExtension(ucStoreLogo.FileName);
                var ext      = Path.GetExtension(ucStoreLogo.FileName);

                fileName = Text.CleanFileName(fileName);

                if (DiskStorage.UploadStoreImage(HccApp.CurrentStore, ucStoreLogo.TempImagePath, ucStoreLogo.FileName))
                {
                    HccApp.CurrentStore.Settings.LogoImage = fileName + ext;
                }
            }

            HccApp.CurrentStore.Settings.ForceAdminSSL = chkUseSSL.Checked;

            HccApp.UpdateCurrentStore();

            return(result);
        }
Exemplo n.º 14
0
        private string ResolveSpecialUrl(string raw)
        {
            // full url
            var tester = raw.Trim().ToLowerInvariant();

            if (tester.StartsWith("http:") || tester.StartsWith("https:") ||
                tester.StartsWith("//"))
            {
                return(raw);
            }

            // tag replaced url {{img}} or {{assets}
            if (tester.StartsWith("{{"))
            {
                return(TagReplacer.ReplaceContentTags(raw, HccApp));
            }

            // app relative url
            if (tester.StartsWith("~"))
            {
                return(ResolveUrl(raw));
            }

            // old style asset
            return(DiskStorage.StoreUrl(
                       HccApp,
                       raw,
                       HccApp.IsCurrentRequestSecure()));
        }
Exemplo n.º 15
0
        public ActionResult AddCoupon()
        {
            var code = Request["couponcode"] ?? string.Empty;

            CurrentCart.AddCouponCode(code.Trim());
            HccApp.CalculateOrderAndSave(CurrentCart);
            return(Redirect(Url.RouteHccUrl(HccRoute.Cart)));
        }
        protected void btnClose_Click(object sender, EventArgs e)
        {
            EnsureStore();

            SaveDisplaySettings();
            HccApp.UpdateCurrentStore();
            NotifyFinishedEditing("EXIT");
        }
Exemplo n.º 17
0
        protected string GetVariantImageUrl(IDataItemContainer cont)
        {
            var v = cont.DataItem as Variant;
            var p = _currentProduct;

            return(DiskStorage.ProductVariantImageUrlMedium(HccApp, p.Bvin, p.ImageFileSmall, v.Bvin,
                                                            HccApp.IsCurrentRequestSecure()));
        }
        public ActionResult GetRatesAsRadioButtons(FormCollection form)
        {
            var result = new ShippingRatesJsonModel();

            var country   = form["country"] ?? string.Empty;
            var firstname = form["firstname"] ?? string.Empty;
            var lastname  = form["lastname"] ?? string.Empty;
            var address   = form["address"] ?? string.Empty;
            var city      = form["city"] ?? string.Empty;
            var state     = form["state"] ?? string.Empty;
            var zip       = form["zip"] ?? string.Empty;
            var orderid   = form["orderid"] ?? string.Empty;

            var order = HccApp.OrderServices.Orders.FindForCurrentStore(orderid);

            order.ShippingAddress.FirstName  = firstname;
            order.ShippingAddress.LastName   = lastname;
            order.ShippingAddress.Line1      = address;
            order.ShippingAddress.City       = city;
            order.ShippingAddress.PostalCode = zip;
            var c = HccApp.GlobalizationServices.Countries.Find(country);

            if (c != null)
            {
                order.ShippingAddress.CountryBvin = country;
                var region = c.Regions.
                             FirstOrDefault(r => r.Abbreviation == state);
                if (region != null)
                {
                    order.ShippingAddress.RegionBvin = region.Abbreviation;
                }
            }

            var rates = HccApp.OrderServices.FindAvailableShippingRates(order);

            if (rates != null && rates.Count > 0)
            {
                var selectedRate = rates.
                                   OfType <ShippingRateDisplay>().
                                   FirstOrDefault(r => r.UniqueKey == order.ShippingMethodUniqueKey);
                if (selectedRate == null)
                {
                    selectedRate = rates[0];
                }

                HccApp.OrderServices.OrdersRequestShippingMethod(selectedRate, order);
            }
            else
            {
                order.ClearShippingPricesAndMethod();
            }

            result.rates = HtmlRendering.ShippingRatesToRadioButtons(rates, 300, order.ShippingMethodUniqueKey);

            HccApp.CalculateOrderAndSave(order);

            return(new PreJsonResult(Web.Json.ObjectToJson(result)));
        }
Exemplo n.º 19
0
        private ProductPageViewModel LoadProductModel(string slug)
        {
            CustomUrl customUrl;
            var       product = HccApp.ParseProductBySlug(slug, out customUrl);

            if (customUrl != null && !IsConcreteItemModule)
            {
                var redirectUrl = HccUrlBuilder.RouteHccUrl(HccRoute.Product, new { slug = customUrl.RedirectToUrl });
                if (customUrl.IsPermanentRedirect)
                {
                    Response.RedirectPermanent(redirectUrl);
                }
                else
                {
                    Response.Redirect(redirectUrl);
                }
            }
            if (product == null)
            {
                StoreExceptionHelper.ShowInfo(Localization.GetString("ProductNotFound"));
            }
            else if (product.Status != ProductStatus.Active)
            {
                StoreExceptionHelper.ShowInfo(Localization.GetString("ProductNotActive"));
            }
            else if (!HccApp.CatalogServices.TestProductAccess(product))
            {
                StoreExceptionHelper.ShowInfo(Localization.GetString("ProductNotEnoughPermission"));
            }

            var model = new ProductPageViewModel {
                LocalProduct = product
            };

            LoadImageUrls(model);
            model.Prices = CreateProductPrices(product);
            LoadRelatedItems(model);
            LoadBundledItems(model);
            model.IsAvailableForWishList = SessionManager.IsUserAuthenticated(HccApp);
            model.AllowReviews           = product.AllowReviews.HasValue
                ? product.AllowReviews.Value
                : HccApp.CurrentStore.Settings.AllowProductReviews;
            LoadAlternateImages(model);
            model.PreRenderedTypeValues = product.RenderTypeProperties();
            model.SwatchHtml            = ImageHelper.GenerateSwatchHtmlForProduct(product, HccApp);
            model.LineItemId            = Request.QueryString["LineItemId"].ConvertToNullable <long>();

            // make the minimum quantity be the new default if necessary, otherwise use the actual default (1)
            if (product.MinimumQty > 0)
            {
                model.Quantity = product.MinimumQty;
            }

            LoadGiftCardAmounts(model);

            return(model);
        }
Exemplo n.º 20
0
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            var urlStoreSettings = HccApp.CurrentStore.Settings.Urls;

            urlStoreSettings.ViewsVirtualPath = ddlViewSets.SelectedValue;

            HccApp.UpdateCurrentStore();

            msg.ShowOk(Localization.GetString("SettingsSuccessful"));
        }
Exemplo n.º 21
0
        private void LoadCategory(Category c)
        {
            NameField.Text      = c.Name;
            LinkToField.Text    = c.CustomPageUrl;
            MetaTitleField.Text = c.MetaTitle;
            chkHidden.Checked   = c.Hidden;

            ucIconImage.ImageUrl = DiskStorage.CategoryIconUrl(HccApp, c.Bvin, c.ImageUrl,
                                                               HccApp.IsCurrentRequestSecure());
        }
Exemplo n.º 22
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                HccApp.CurrentStore.Settings.ApplyVATRules = chkApplyVATRules.Checked;

                HccApp.UpdateCurrentStore();

                SaveChanges();
            }
        }
Exemplo n.º 23
0
        private bool CheckForStockOnItems(CartViewModel model)
        {
            var result = HccApp.CheckForStockOnItems(model.CurrentOrder);

            if (result.Success)
            {
                return(true);
            }
            FlashFailure(result.Message);
            return(false);
        }
Exemplo n.º 24
0
        private void UpdateLogoImage()
        {
            ucStoreLogo.ImageUrl = HccApp.CurrentStore.Settings.LogoImageFullUrl(HccApp, Page.Request.IsSecureConnection);

            if (string.IsNullOrWhiteSpace(HccApp.CurrentStore.Settings.LogoImage))
            {
                ucStoreLogo.ImageUrl = ResolveUrl("~/DesktopModules/Hotcakes/Core/Admin/Images/MissingImage.png");
            }

            HccApp.UpdateCurrentStore();
        }
Exemplo n.º 25
0
        public ActionResult RemoveCoupon()
        {
            var  couponid = Request["couponid"] ?? string.Empty;
            long tempid   = 0;

            long.TryParse(couponid, out tempid);

            CurrentCart.RemoveCouponCode(tempid);
            HccApp.CalculateOrderAndSave(CurrentCart);

            return(Redirect(Url.RouteHccUrl(HccRoute.Cart)));
        }
Exemplo n.º 26
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                HccApp.CurrentStore.Settings.ProductReviewCount    = int.Parse(txtProductReviewCount.Text.Trim());
                HccApp.CurrentStore.Settings.ProductReviewModerate = chkProductReviewModerate.Checked;
                HccApp.CurrentStore.Settings.AllowProductReviews   = chkAllowProductReviews.Checked;
                HccApp.UpdateCurrentStore();

                ucMessageBox.ShowOk(Localization.GetString("SettingsSuccessful"));
            }
        }
Exemplo n.º 27
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var sett = new StoreSettingsAddressTools(HccApp.CurrentStore.Settings)
            {
                UseAddressValidation = chkEnable.Checked,
                AddressToolsID       = txtToolsID.Text
            };

            HccApp.UpdateCurrentStore();

            ucMessageBox.ShowOk(Localization.GetString("SettingsSuccessful"));
        }