public MaterialProcessor() { if (!ProductAttributeHelper.Bind(this)) { throw new Exception("The product attribute 'Material' could not be loaded."); } }
public LiningProcessor() { if (!ProductAttributeHelper.Bind(this)) { throw new Exception("The product attribute 'Voering' could not be loaded."); } }
/// <summary> /// Gets the shopping cart unit price (one item) /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <param name="customer">The customer</param> /// <param name="includeDiscounts">A value indicating whether include discounts or not for price computation</param> /// <returns>Shopping cart unit price (one item)</returns> public static decimal GetUnitPrice(ShoppingCartItem shoppingCartItem, Customer customer, bool includeDiscounts) { decimal finalPrice = decimal.Zero; ProductVariant productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) { decimal attributesTotalPrice = decimal.Zero; ProductVariantAttributeValueCollection pvaValues = ProductAttributeHelper.ParseProductVariantAttributeValues(shoppingCartItem.AttributesXML); foreach (ProductVariantAttributeValue pvaValue in pvaValues) { attributesTotalPrice += pvaValue.PriceAdjustment; } finalPrice = GetFinalPrice(productVariant, customer, attributesTotalPrice, includeDiscounts); if (productVariant.TierPrices.Count > 0) { decimal tierPrice = GetTierPrice(productVariant, shoppingCartItem.Quantity); finalPrice = Math.Min(finalPrice, tierPrice); } } finalPrice = Math.Round(finalPrice, 2); return(finalPrice); }
public DescriptionProcessor() { if (!ProductAttributeHelper.Bind(this)) { throw new Exception("One of the product attributes could not be loaded."); } }
public DeliveryTimeProcessor() { if (!ProductAttributeHelper.Bind(this)) { throw new Exception("The product attribute 'DeliveryTime' could not be loaded."); } }
/// <summary> /// Gets the shopping cart unit price (one item) /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <param name="customer">The customer</param> /// <param name="includeDiscounts">A value indicating whether include discounts or not for price computation</param> /// <returns>Shopping cart unit price (one item)</returns> public static decimal GetUnitPrice(ShoppingCartItem shoppingCartItem, Customer customer, bool includeDiscounts) { decimal finalPrice = decimal.Zero; var productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) { decimal attributesTotalPrice = decimal.Zero; var pvaValues = ProductAttributeHelper.ParseProductVariantAttributeValues(shoppingCartItem.AttributesXml); foreach (var pvaValue in pvaValues) { attributesTotalPrice += pvaValue.PriceAdjustment; } if (productVariant.CustomerEntersPrice) { finalPrice = shoppingCartItem.CustomerEnteredPrice; } else { finalPrice = GetFinalPrice(productVariant, customer, attributesTotalPrice, includeDiscounts, shoppingCartItem.Quantity); } } finalPrice = Math.Round(finalPrice, 2); return(finalPrice); }
public FitProcessor() { if (!ProductAttributeHelper.Bind(this)) { throw new Exception("The product attribute 'Pasvorm' could not be loaded."); } }
public GenderProcessor() { if (!ProductAttributeHelper.Bind(this)) { throw new Exception("The product attribute 'Gender' could not be loaded."); } }
public WashingInstructionsProcessor() { if (!ProductAttributeHelper.Bind(this)) { throw new Exception("The product attribute 'WashingInstructions' could not be loaded."); } }
public CollectionProcessor(Vendor vendor) { if (!ProductAttributeHelper.Bind(this, vendor)) { throw new Exception("One of the product attributes could not be loaded."); } }
public AreaProcessor() { if (!ProductAttributeHelper.Bind(this)) { throw new Exception("The product attribute 'Terrein' could not be loaded."); } }
public CollectionProcessor() { if (!ProductAttributeHelper.Bind(this)) { throw new Exception("The product attribute 'Collectie' could not be loaded."); } }
public SeasonProcessor() { if (!ProductAttributeHelper.Bind(this)) { throw new Exception("The product attribute 'Seizoen' could not be loaded."); } }
public string GetAttributeDescription(ShoppingCartItem shoppingCartItem) { string result = ProductAttributeHelper.FormatAttributes(shoppingCartItem.ProductVariant, shoppingCartItem.AttributesXml); if (!String.IsNullOrEmpty(result)) { result = "<br />" + result; } return(result); }
public string GetAttributeDescription(ShoppingCartItem shoppingCartItem) { Customer customer = shoppingCartItem.CustomerSession.Customer; string result = ProductAttributeHelper.FormatAttributes(shoppingCartItem.ProductVariant, shoppingCartItem.AttributesXml, customer, "<br />"); if (!String.IsNullOrEmpty(result)) { result = "<br />" + result; } return(result); }
protected void gvCombinations_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var productVariantAttribute = (ProductVariantAttributeCombination)e.Row.DataItem; Button btnUpdate = e.Row.FindControl("btnUpdate") as Button; if (btnUpdate != null) { btnUpdate.CommandArgument = e.Row.RowIndex.ToString(); } ProductVariant productVariant = ProductManager.GetProductVariantById(this.ProductVariantId); if (productVariant == null) { return; } Label lblAttributes = e.Row.FindControl("lblAttributes") as Label; lblAttributes.Text = ProductAttributeHelper.FormatAttributes(productVariant, productVariantAttribute.AttributesXml, NopContext.Current.User, "<br />", true, false, true, false); Label lblWarnings = e.Row.FindControl("lblWarnings") as Label; List <string> warnings = ShoppingCartManager.GetShoppingCartItemAttributeWarnings(ShoppingCartTypeEnum.ShoppingCart, productVariant.ProductVariantId, productVariantAttribute.AttributesXml, 1, false); if (warnings.Count > 0) { StringBuilder warningsSb = new StringBuilder(); for (int i = 0; i < warnings.Count; i++) { warningsSb.Append(Server.HtmlEncode(warnings[i])); if (i != warnings.Count - 1) { warningsSb.Append("<br />"); } } lblWarnings.Visible = true; lblWarnings.Text = warningsSb.ToString(); } else { lblWarnings.Visible = false; } } }
/// <summary> /// Gets discount amount /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <param name="customer">The customer</param> /// <returns>Discount amount</returns> public static decimal GetDiscountAmount(ShoppingCartItem shoppingCartItem, Customer customer) { decimal discountAmount = decimal.Zero; ProductVariant productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) { decimal attributesTotalPrice = decimal.Zero; ProductVariantAttributeValueCollection pvaValues = ProductAttributeHelper.ParseProductVariantAttributeValues(shoppingCartItem.AttributesXML); foreach (ProductVariantAttributeValue pvaValue in pvaValues) { attributesTotalPrice += pvaValue.PriceAdjustment; } decimal productVariantDiscountAmount = GetDiscountAmount(productVariant, customer, attributesTotalPrice); discountAmount = productVariantDiscountAmount * shoppingCartItem.Quantity; } discountAmount = Math.Round(discountAmount, 2); return(discountAmount); }
/// <summary> /// Gets discount amount /// </summary> /// <param name="shoppingCartItem">The shopping cart item</param> /// <param name="customer">The customer</param> /// <param name="appliedDiscount">Applied discount</param> /// <returns>Discount amount</returns> public static decimal GetDiscountAmount(ShoppingCartItem shoppingCartItem, Customer customer, out Discount appliedDiscount) { appliedDiscount = null; decimal discountAmount = decimal.Zero; var productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) { decimal attributesTotalPrice = decimal.Zero; var pvaValues = ProductAttributeHelper.ParseProductVariantAttributeValues(shoppingCartItem.AttributesXml); foreach (var pvaValue in pvaValues) { attributesTotalPrice += pvaValue.PriceAdjustment; } decimal productVariantDiscountAmount = GetDiscountAmount(productVariant, customer, attributesTotalPrice, shoppingCartItem.Quantity, out appliedDiscount); discountAmount = productVariantDiscountAmount * shoppingCartItem.Quantity; } //discountAmount = Math.Round(discountAmount, 2, MidpointRounding.AwayFromZero); return(discountAmount); }
/// <summary> /// Add a product variant to shopping cart /// </summary> /// <param name="ShoppingCartType">Shopping cart type</param> /// <param name="ProductVariantID">Product variant identifier</param> /// <param name="SelectedAttributes">Selected attributes</param> /// <param name="Quantity">Quantity</param> /// <returns>Warnings</returns> public static List <string> AddToCart(ShoppingCartTypeEnum ShoppingCartType, int ProductVariantID, string SelectedAttributes, int Quantity) { List <string> warnings = new List <string>(); if (ShoppingCartType == ShoppingCartTypeEnum.Wishlist && !SettingManager.GetSettingValueBoolean("Common.EnableWishlist")) { return(warnings); } if (NopContext.Current.Session == null) { NopContext.Current.Session = NopContext.Current.GetSession(true); } Guid CustomerSessionGUID = NopContext.Current.Session.CustomerSessionGUID; CustomerManager.ResetCheckoutData(NopContext.Current.Session.CustomerID, false); ShoppingCart Cart = GetShoppingCartByCustomerSessionGUID(ShoppingCartType, CustomerSessionGUID); ShoppingCartItem shoppingCartItem = null; foreach (ShoppingCartItem _shoppingCartItem in Cart) { if (_shoppingCartItem.ProductVariantID == ProductVariantID) { if (ProductAttributeHelper.ParseProductVariantAttributeIDs(_shoppingCartItem.AttributesXML).Count == ProductAttributeHelper.ParseProductVariantAttributeIDs(SelectedAttributes).Count) { bool attributeEquals = true; ProductVariantAttributeCollection pva1Collection = ProductAttributeHelper.ParseProductVariantAttributes(SelectedAttributes); ProductVariantAttributeCollection pva2Collection = ProductAttributeHelper.ParseProductVariantAttributes(_shoppingCartItem.AttributesXML); foreach (ProductVariantAttribute pva1 in pva1Collection) { foreach (ProductVariantAttribute pva2 in pva2Collection) { if (pva1.ProductVariantAttributeID == pva2.ProductVariantAttributeID) { List <string> pvaValues1Str = ProductAttributeHelper.ParseValues(SelectedAttributes, pva1.ProductVariantAttributeID); List <string> pvaValues2Str = ProductAttributeHelper.ParseValues(_shoppingCartItem.AttributesXML, pva2.ProductVariantAttributeID); if (pvaValues1Str.Count == pvaValues2Str.Count) { foreach (string str1 in pvaValues1Str) { bool hasAttribute = false; foreach (string str2 in pvaValues2Str) { if (str1.Trim().ToLower() == str2.Trim().ToLower()) { hasAttribute = true; break; } } if (!hasAttribute) { attributeEquals = false; break; } } } else { attributeEquals = false; break; } } } } if (attributeEquals) { shoppingCartItem = _shoppingCartItem; } } } } DateTime now = DateTime.Now; if (shoppingCartItem != null) { int newQuantity = shoppingCartItem.Quantity + Quantity; warnings.AddRange(GetShoppingCartItemWarnings(ShoppingCartType, ProductVariantID, SelectedAttributes, newQuantity)); if (warnings.Count == 0) { UpdateShoppingCartItem(shoppingCartItem.ShoppingCartItemID, ShoppingCartType, CustomerSessionGUID, ProductVariantID, SelectedAttributes, newQuantity, shoppingCartItem.CreatedOn, now); } } else { warnings.AddRange(GetShoppingCartItemWarnings(ShoppingCartType, ProductVariantID, SelectedAttributes, Quantity)); if (warnings.Count == 0) { InsertShoppingCartItem(ShoppingCartType, CustomerSessionGUID, ProductVariantID, SelectedAttributes, Quantity, now, now); } } return(warnings); }
/// <summary> /// Validates whether this shopping cart item is allowed /// </summary> /// <param name="ShoppingCartType">Shopping cart type</param> /// <param name="ProductVariantID">Product variant identifier</param> /// <param name="SelectedAttributes">Selected attributes</param> /// <param name="Quantity">Quantity</param> /// <returns>Warnings</returns> public static List <string> GetShoppingCartItemWarnings(ShoppingCartTypeEnum ShoppingCartType, int ProductVariantID, string SelectedAttributes, int Quantity) { List <string> warnings = new List <string>(); ProductVariant productVariant = ProductManager.GetProductVariantByID(ProductVariantID); if (productVariant == null) { warnings.Add(string.Format("Product variant (ID={0}) can not be loaded", ProductVariantID)); return(warnings); } Product product = productVariant.Product; if (product == null) { warnings.Add(string.Format("Product (ID={0}) can not be loaded", productVariant.ProductID)); return(warnings); } if (product.Deleted || productVariant.Deleted) { warnings.Add("Product is deleted"); return(warnings); } if (!product.Published || !productVariant.Published) { warnings.Add("Product is not published"); } if (productVariant.DisableBuyButton) { warnings.Add("Buying is disabled"); } if (Quantity < productVariant.OrderMinimumQuantity) { warnings.Add(string.Format(LocalizationManager.GetLocaleResourceString("ShoppingCart.MinimumQuantity"), productVariant.OrderMinimumQuantity)); } if (Quantity > productVariant.OrderMaximumQuantity) { warnings.Add(string.Format(LocalizationManager.GetLocaleResourceString("ShoppingCart.MaximumQuantity"), productVariant.OrderMaximumQuantity)); } if (productVariant.ManageInventory) { if (productVariant.StockQuantity < Quantity) { int maximumQuantityCanBeAdded = productVariant.StockQuantity; warnings.Add(string.Format(LocalizationManager.GetLocaleResourceString("ShoppingCart.QuantityExceedsStock"), maximumQuantityCanBeAdded)); } } if (productVariant.AvailableStartDateTime.HasValue) { DateTime now = DateTimeHelper.ConvertToUtcTime(DateTime.Now); if (productVariant.AvailableStartDateTime.Value.CompareTo(now) > 0) { warnings.Add("Product is not available"); } } else if (productVariant.AvailableEndDateTime.HasValue) { DateTime now = DateTimeHelper.ConvertToUtcTime(DateTime.Now); if (productVariant.AvailableEndDateTime.Value.CompareTo(now) < 0) { warnings.Add("Product is not available"); } } //selected attributes ProductVariantAttributeCollection pva1Collection = ProductAttributeHelper.ParseProductVariantAttributes(SelectedAttributes); foreach (ProductVariantAttribute pva1 in pva1Collection) { ProductVariant pv1 = pva1.ProductVariant; if (pv1 != null) { if (pv1.ProductVariantID != productVariant.ProductVariantID) { warnings.Add("Attribute error"); } } else { warnings.Add("Attribute error"); return(warnings); } } //existing product attributes ProductVariantAttributeCollection pva2Collection = productVariant.ProductVariantAttributes; foreach (ProductVariantAttribute pva2 in pva2Collection) { if (pva2.IsRequired) { bool found = false; //selected attributes foreach (ProductVariantAttribute pva1 in pva1Collection) { if (pva1.ProductVariantAttributeID == pva2.ProductVariantAttributeID) { List <string> pvaValuesStr = ProductAttributeHelper.ParseValues(SelectedAttributes, pva1.ProductVariantAttributeID); foreach (string str1 in pvaValuesStr) { if (!String.IsNullOrEmpty(str1.Trim())) { found = true; break; } } } } //if not found if (!found) { if (!string.IsNullOrEmpty(pva2.TextPrompt)) { warnings.Add(pva2.TextPrompt); } else { warnings.Add(string.Format(LocalizationManager.GetLocaleResourceString("ShoppingCart.SelectAttribute"), pva2.ProductAttribute.Name)); } } } } return(warnings); }
/// <summary> /// Post cart to google /// </summary> /// <param name="Req">Pre-generated request</param> /// <param name="Cart">Shopping cart</param> /// <returns>Response</returns> public GCheckoutResponse PostCartToGoogle(CheckoutShoppingCartRequest Req, NopSolutions.NopCommerce.BusinessLogic.Orders.ShoppingCart Cart) { foreach (NopSolutions.NopCommerce.BusinessLogic.Orders.ShoppingCartItem sci in Cart) { ProductVariant productVariant = sci.ProductVariant; if (productVariant != null) { string pvAttributeDescription = ProductAttributeHelper.FormatAttributes(productVariant, sci.AttributesXML, NopContext.Current.User, ", ", false); string fullName = productVariant.FullProductName; string description = pvAttributeDescription; decimal unitPrice = TaxManager.GetPrice(sci.ProductVariant, PriceHelper.GetUnitPrice(sci, NopContext.Current.User, true)); Req.AddItem(fullName, description, sci.ShoppingCartItemID.ToString(), unitPrice, sci.Quantity); } } decimal shoppingCartSubTotalDiscount; decimal shoppingCartSubTotal = ShoppingCartManager.GetShoppingCartSubTotal(Cart, NopContext.Current.User, out shoppingCartSubTotalDiscount); if (shoppingCartSubTotalDiscount > decimal.Zero) { Req.AddItem("Discount", string.Empty, string.Empty, (decimal)(-1.0) * shoppingCartSubTotalDiscount, 1); } bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart); if (shoppingCartRequiresShipping) { string shippingError = string.Empty; //TODO AddMerchantCalculatedShippingMethod //TODO AddCarrierCalculatedShippingOption ShippingOptionCollection shippingOptions = ShippingManager.GetShippingOptions(Cart, NopContext.Current.User, null, ref shippingError); foreach (ShippingOption shippingOption in shippingOptions) { Req.AddFlatRateShippingMethod(shippingOption.Name, TaxManager.GetShippingPrice(shippingOption.Rate, NopContext.Current.User)); } } //add only US, GB states //CountryCollection countries = CountryManager.GetAllCountries(); //foreach (Country country in countries) //{ // foreach (StateProvince state in country.StateProvinces) // { // TaxByStateProvinceCollection taxByStateProvinceCollection = TaxByStateProvinceManager.GetAllByStateProvinceID(state.StateProvinceID); // foreach (TaxByStateProvince taxByStateProvince in taxByStateProvinceCollection) // { // if (!String.IsNullOrEmpty(state.Abbreviation)) // { // Req.AddStateTaxRule(state.Abbreviation, (double)taxByStateProvince.Percentage, false); // } // } // } //} XmlDocument customerInfoDoc = new XmlDocument(); XmlElement customerInfo = customerInfoDoc.CreateElement("CustomerInfo"); customerInfo.SetAttribute("CustomerID", NopContext.Current.User.CustomerID.ToString()); customerInfo.SetAttribute("CustomerLanguageID", NopContext.Current.WorkingLanguage.LanguageID.ToString()); customerInfo.SetAttribute("CustomerCurrencyID", NopContext.Current.WorkingCurrency.CurrencyID.ToString()); Req.AddMerchantPrivateDataNode(customerInfo); Req.ContinueShoppingUrl = CommonHelper.GetStoreLocation(false); Req.EditCartUrl = CommonHelper.GetStoreLocation(false) + "ShoppingCart.aspx"; GCheckoutResponse Resp = Req.Send(); return(Resp); }
/// <summary> /// Post cart to google /// </summary> /// <param name="req">Pre-generated request</param> /// <param name="cart">Shopping cart</param> /// <returns>Response</returns> public GCheckoutResponse PostCartToGoogle(CheckoutShoppingCartRequest req, NopSolutions.NopCommerce.BusinessLogic.Orders.ShoppingCart cart) { //items foreach (NopSolutions.NopCommerce.BusinessLogic.Orders.ShoppingCartItem sci in cart) { ProductVariant productVariant = sci.ProductVariant; if (productVariant != null) { string description = ProductAttributeHelper.FormatAttributes(productVariant, sci.AttributesXml, NopContext.Current.User, ", ", false); string fullName = productVariant.FullProductName; decimal unitPrice = TaxManager.GetPrice(sci.ProductVariant, PriceHelper.GetUnitPrice(sci, NopContext.Current.User, true)); req.AddItem(fullName, description, sci.ShoppingCartItemId.ToString(), unitPrice, sci.Quantity); } } //discounts decimal subTotalDiscountBase = decimal.Zero; Discount appliedDiscount = null; //List<AppliedGiftCard> appliedGiftCards = null; decimal subtotalBaseWithoutPromo = decimal.Zero; decimal subtotalBaseWithPromo = decimal.Zero; string SubTotalError = ShoppingCartManager.GetShoppingCartSubTotal(cart, NopContext.Current.User, out subTotalDiscountBase, out appliedDiscount, out subtotalBaseWithoutPromo, out subtotalBaseWithPromo); if (subTotalDiscountBase > decimal.Zero) { req.AddItem("Discount", string.Empty, string.Empty, (decimal)(-1.0) * subTotalDiscountBase, 1); } //foreach (AppliedGiftCard agc in appliedGiftCards) //{ // req.AddItem(string.Format("Gift Card - {0}", agc.GiftCard.GiftCardCouponCode), string.Empty, string.Empty, (decimal)(-1.0) * agc.AmountCanBeUsed, 1); //} bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(cart); if (shoppingCartRequiresShipping) { string shippingError = string.Empty; //TODO AddMerchantCalculatedShippingMethod //TODO AddCarrierCalculatedShippingOption ShippingOptionCollection shippingOptions = ShippingManager.GetShippingOptions(cart, NopContext.Current.User, null, ref shippingError); foreach (ShippingOption shippingOption in shippingOptions) { req.AddFlatRateShippingMethod(shippingOption.Name, TaxManager.GetShippingPrice(shippingOption.Rate, NopContext.Current.User)); } } //add only US, GB states //CountryCollection countries = CountryManager.GetAllCountries(); //foreach (Country country in countries) //{ // foreach (StateProvince state in country.StateProvinces) // { // TaxByStateProvinceCollection taxByStateProvinceCollection = TaxByStateProvinceManager.GetAllByStateProvinceID(state.StateProvinceID); // foreach (TaxByStateProvince taxByStateProvince in taxByStateProvinceCollection) // { // if (!String.IsNullOrEmpty(state.Abbreviation)) // { // Req.AddStateTaxRule(state.Abbreviation, (double)taxByStateProvince.Percentage, false); // } // } // } //} XmlDocument customerInfoDoc = new XmlDocument(); XmlElement customerInfo = customerInfoDoc.CreateElement("CustomerInfo"); customerInfo.SetAttribute("CustomerID", NopContext.Current.User.CustomerId.ToString()); customerInfo.SetAttribute("CustomerLanguageID", NopContext.Current.WorkingLanguage.LanguageId.ToString()); customerInfo.SetAttribute("CustomerCurrencyID", NopContext.Current.WorkingCurrency.CurrencyId.ToString()); req.AddMerchantPrivateDataNode(customerInfo); req.ContinueShoppingUrl = CommonHelper.GetStoreLocation(false); req.EditCartUrl = CommonHelper.GetStoreLocation(false) + "ShoppingCart.aspx"; GCheckoutResponse resp = req.Send(); return(resp); }
public string GetAttributeDescription(ShoppingCartItem shoppingCartItem) { string result = ProductAttributeHelper.FormatAttributes(shoppingCartItem.ProductVariant, shoppingCartItem.AttributesXML); return(result); }
protected override void ExecuteVendorTask() { _monitoring = new FeeblMonitoring(); _monitoring.Notify(Name, 0); if (Location.IsNullOrWhiteSpace()) { TraceError("The connector setting '{0}' does not exists or is empty!", Constants.Vendor.Setting.Location); } else { var locationInfo = new DirectoryInfo(Location); if (!locationInfo.FullName.EndsWith("$") && !locationInfo.Exists) { TraceError("The directory '{0}' does not exists!", locationInfo.FullName); } else if (!locationInfo.FullName.EndsWith("$") && !locationInfo.HasAccess(FileSystemRights.FullControl)) { TraceError("The user '{0}' has insufficient access over the directory '{1}'!", WindowsIdentity.GetCurrent().Name, locationInfo.FullName); } else if (ProductAttributeHelper.Bind(PropertyStore, Context, TraceSource)) { Languages = Unit.Scope .Repository <Language>() .GetAll(language => language.Name == Constants.Language.English) .ToArray(); TariffVendors = Unit.Scope .Repository <Vendor>() .Include(vendor => vendor.VendorSettings) .GetAll(vendor => vendor.ParentVendorID == VendorID) .AsEnumerable() .Where(vendor => vendor.GetVendorSetting(Constants.Vendor.Setting.IsTariff, false) && !vendor.GetVendorSetting(Constants.Vendor.Setting.CountryCode).IsNullOrWhiteSpace() && !vendor.GetVendorSetting(Constants.Vendor.Setting.CurrencyCode).IsNullOrWhiteSpace()) .ToDictionary(GetTariffCode); var files = locationInfo.GetFiles("*.csv", SearchOption.TopDirectoryOnly); TraceInformation("Found {0} CSV-files for import!", files.Length); foreach (var fileInfo in files) { TraceInformation("Importing the file '{0}'...", fileInfo); var articles = GetArticles(fileInfo.FullName); if (articles != null) { var enumerableArticles = articles as Article[] ?? articles.ToArray(); ImportTariffVendors(enumerableArticles); var vendorAssortmentItems = GetVendorAssortments(enumerableArticles).ToArray(); var success = true; foreach (var vendorAssortmentGrouping in vendorAssortmentItems.GroupBy(vendorAssortmentItem => vendorAssortmentItem.VendorProduct.VendorID)) { TraceInformation("Importing assortment for vendor '{0}'...", vendorAssortmentGrouping.Key != VendorID ? Unit.Scope.Repository <Vendor>().GetSingle(vendor => vendor.VendorID == vendorAssortmentGrouping.Key).Name : VendorName); var bulkConfig = new VendorAssortmentBulkConfiguration { IsPartialAssortment = true }; using (var bulk = new VendorAssortmentBulk(vendorAssortmentGrouping, vendorAssortmentGrouping.Key, VendorID, bulkConfig)) { try { bulk.Init(Unit.Context); bulk.Sync(Unit.Context); } catch (Exception exception) { success = false; TraceCritical(exception); } } } fileInfo.CopyTo(fileInfo.FullName + (success ? ".processed" : ".failed"), true); fileInfo.Delete(); } } ImportProductConfiguration(PropertyStore.ColorCode, PropertyStore.SizeCode); ImportProductGroups(); } } _monitoring.Notify(Name, 1); }
protected void OnCommand(object source, CommandEventArgs e) { var pv = ProductVariant; if (pv == null) { return; } string attributes = ctrlProductAttributes.SelectedAttributes; decimal customerEnteredPrice = txtCustomerEnteredPrice.Value; decimal customerEnteredPriceConverted = this.CurrencyService.ConvertCurrency(customerEnteredPrice, NopContext.Current.WorkingCurrency, this.CurrencyService.PrimaryStoreCurrency); int quantity = txtQuantity.Value; //gift cards if (pv.IsGiftCard) { string recipientName = ctrlGiftCardAttributes.RecipientName; string recipientEmail = ctrlGiftCardAttributes.RecipientEmail; string senderName = ctrlGiftCardAttributes.SenderName; string senderEmail = ctrlGiftCardAttributes.SenderEmail; string giftCardMessage = ctrlGiftCardAttributes.GiftCardMessage; attributes = ProductAttributeHelper.AddGiftCardAttribute(attributes, recipientName, recipientEmail, senderName, senderEmail, giftCardMessage); } try { if (e.CommandName == "AddToCart") { string sep = "<br />"; var addToCartWarnings = this.ShoppingCartService.AddToCart( ShoppingCartTypeEnum.ShoppingCart, pv.ProductVariantId, attributes, customerEnteredPriceConverted, quantity); if (addToCartWarnings.Count == 0) { if (this.SettingManager.GetSettingValueBoolean("Display.Products.DisplayCartAfterAddingProduct")) { //redirect to shopping cart page Response.Redirect(SEOHelper.GetShoppingCartUrl()); } else { //display notification message this.DisplayAlertMessage(GetLocaleResourceString("Products.ProductHasBeenAddedToTheCart")); } } else { var addToCartWarningsSb = new StringBuilder(); for (int i = 0; i < addToCartWarnings.Count; i++) { addToCartWarningsSb.Append(Server.HtmlEncode(addToCartWarnings[i])); if (i != addToCartWarnings.Count - 1) { addToCartWarningsSb.Append(sep); } } string errorFull = addToCartWarningsSb.ToString(); lblError.Text = errorFull; if (this.SettingManager.GetSettingValueBoolean("Common.ShowAlertForProductAttributes")) { this.DisplayAlertMessage(errorFull.Replace(sep, "\\n")); } } } if (e.CommandName == "AddToWishlist") { string sep = "<br />"; var addToCartWarnings = this.ShoppingCartService.AddToCart( ShoppingCartTypeEnum.Wishlist, pv.ProductVariantId, attributes, customerEnteredPriceConverted, quantity); if (addToCartWarnings.Count == 0) { Response.Redirect(SEOHelper.GetWishlistUrl()); } else { var addToCartWarningsSb = new StringBuilder(); for (int i = 0; i < addToCartWarnings.Count; i++) { addToCartWarningsSb.Append(Server.HtmlEncode(addToCartWarnings[i])); if (i != addToCartWarnings.Count - 1) { addToCartWarningsSb.Append(sep); } } string errorFull = addToCartWarningsSb.ToString(); lblError.Text = errorFull; if (this.SettingManager.GetSettingValueBoolean("Common.ShowAlertForProductAttributes")) { this.DisplayAlertMessage(errorFull.Replace(sep, "\\n")); } } } } catch (Exception exc) { this.LogService.InsertLog(LogTypeEnum.CustomerError, exc.Message, exc); lblError.Text = Server.HtmlEncode(exc.Message); } }
protected void rptVariants_OnItemCommand(Object source, RepeaterCommandEventArgs e) { if (e.CommandName == "AddToCart" || e.CommandName == "AddToWishlist") { var txtQuantity = e.Item.FindControl("txtQuantity") as NumericTextBox; var txtCustomerEnteredPrice = e.Item.FindControl("txtCustomerEnteredPrice") as NumericTextBox; var productVariantId = e.Item.FindControl("ProductVariantId") as Label; var ctrlProductAttributes = e.Item.FindControl("ctrlProductAttributes") as ProductAttributesControl; var txtRecipientName = e.Item.FindControl("txtRecipientName") as TextBox; var txtRecipientEmail = e.Item.FindControl("txtRecipientEmail") as TextBox; var txtSenderName = e.Item.FindControl("txtSenderName") as TextBox; var txtSenderEmail = e.Item.FindControl("txtSenderEmail") as TextBox; var txtGiftCardMessage = e.Item.FindControl("txtGiftCardMessage") as TextBox; var lblError = e.Item.FindControl("lblError") as Label; var pv = ProductManager.GetProductVariantById(Convert.ToInt32(productVariantId.Text)); if (pv == null) { return; } string attributes = ctrlProductAttributes.SelectedAttributes; decimal customerEnteredPrice = txtCustomerEnteredPrice.Value; decimal customerEnteredPriceConverted = CurrencyManager.ConvertCurrency(customerEnteredPrice, NopContext.Current.WorkingCurrency, CurrencyManager.PrimaryStoreCurrency); int quantity = txtQuantity.Value; //gift cards if (pv.IsGiftCard) { string recipientName = txtRecipientName.Text; string recipientEmail = txtRecipientEmail.Text; string senderName = txtSenderName.Text; string senderEmail = txtSenderEmail.Text; string giftCardMessage = txtGiftCardMessage.Text; attributes = ProductAttributeHelper.AddGiftCardAttribute(attributes, recipientName, recipientEmail, senderName, senderEmail, giftCardMessage); } try { if (e.CommandName == "AddToCart") { string sep = "<br />"; List <string> addToCartWarnings = ShoppingCartManager.AddToCart( ShoppingCartTypeEnum.ShoppingCart, pv.ProductVariantId, attributes, customerEnteredPriceConverted, quantity); if (addToCartWarnings.Count == 0) { Response.Redirect("~/shoppingcart.aspx"); } else { StringBuilder addToCartWarningsSb = new StringBuilder(); for (int i = 0; i < addToCartWarnings.Count; i++) { addToCartWarningsSb.Append(Server.HtmlEncode(addToCartWarnings[i])); if (i != addToCartWarnings.Count - 1) { addToCartWarningsSb.Append(sep); } } string errorFull = addToCartWarningsSb.ToString(); lblError.Text = errorFull; if (SettingManager.GetSettingValueBoolean("Common.ShowAlertForProductAttributes")) { this.DisplayAlertMessage(errorFull.Replace(sep, "\\n")); } } } if (e.CommandName == "AddToWishlist") { string sep = "<br />"; var addToCartWarnings = ShoppingCartManager.AddToCart( ShoppingCartTypeEnum.Wishlist, pv.ProductVariantId, attributes, customerEnteredPriceConverted, quantity); if (addToCartWarnings.Count == 0) { Response.Redirect("~/wishlist.aspx"); } else { var addToCartWarningsSb = new StringBuilder(); for (int i = 0; i < addToCartWarnings.Count; i++) { addToCartWarningsSb.Append(Server.HtmlEncode(addToCartWarnings[i])); if (i != addToCartWarnings.Count - 1) { addToCartWarningsSb.Append(sep); } } string errorFull = addToCartWarningsSb.ToString(); lblError.Text = errorFull; if (SettingManager.GetSettingValueBoolean("Common.ShowAlertForProductAttributes")) { this.DisplayAlertMessage(errorFull.Replace(sep, "\\n")); } } } } catch (Exception exc) { LogManager.InsertLog(LogTypeEnum.CustomerError, exc.Message, exc); lblError.Text = Server.HtmlEncode(exc.Message); } } }