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); }
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); }
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); } }
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)); }
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))); }
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()); }
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"))); }
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))); }
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); }
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); }
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); }
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())); }
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"); }
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))); }
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); }
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")); }
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()); }
protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { HccApp.CurrentStore.Settings.ApplyVATRules = chkApplyVATRules.Checked; HccApp.UpdateCurrentStore(); SaveChanges(); } }
private bool CheckForStockOnItems(CartViewModel model) { var result = HccApp.CheckForStockOnItems(model.CurrentOrder); if (result.Success) { return(true); } FlashFailure(result.Message); return(false); }
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(); }
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))); }
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")); } }
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")); }