/// <summary> /// The get default sku price. /// </summary> /// <param name="prodInfo"> /// The prod info. /// </param> /// <returns> /// The get default sku price. /// </returns> private string getDefaultSKUPrice(ProductInfo_V02 prodInfo) { if (HLConfigManager.Configurations.ShoppingCartConfiguration.DisplayRetailPrice) { if (prodInfo.DefaultSKU != null) { SKU_V01 HLSKU; if (AllSKUS.TryGetValue(prodInfo.DefaultSKU.SKU, out HLSKU)) { return(getAmountString(HLSKU.CatalogItem != null ? HLSKU.CatalogItem.ListPrice : 0.0M)); } } } return(string.Empty); }
/// <summary> /// The collect all products. /// </summary> /// <param name="currentCategory"> /// The current category. /// </param> /// <param name="itemList"> /// The item list. /// </param> private void collectAllProducts(bool bShowAllInventory, Category_V02 currentCategory, List <UIProductInfo> itemList) { if (currentCategory == null) { return; } if (currentCategory.SubCategories != null) { foreach (Category_V02 sub in currentCategory.SubCategories) { collectAllProducts(bShowAllInventory, sub, itemList); } } if (currentCategory.Products != null) { int sortIndx = 0; if (HLConfigManager.Configurations.DOConfiguration.AllowHAP && SessionInfo.IsHAPMode && ShoppingCart.OrderCategory == OrderCategoryType.HSO) { itemList.AddRange( (from p in currentCategory.Products where p.TypeOfProduct == ProductType.Product && checkProductAvailability(bShowAllInventory, p) && (from s in p.SKUs where s.IsDisplayable select s).Count() > 0 select new UIProductInfo(currentCategory.ID, getDefaultSKUImagePath(p), p.DisplayName, p.ID, getDefaultSKUPrice(p), sortIndx++)).ToList() ); } else { if (IsChina && ShoppingCart.OrderCategory == OrderCategoryType.ETO) { string[] words = null; string eligibleSKu = string.Empty; var rsp = MyHerbalife3.Ordering.Providers.China.OrderProvider.GetEventEligibility(ShoppingCart.DistributorID); if (rsp != null && rsp.IsEligible) { words = rsp.Remark.Split('|'); eligibleSKu = words[words.Length - 2]; } SKU_V01 etoSku; AllSKUS.TryGetValue(eligibleSKu, out etoSku); if (etoSku != null) { var skuETO = new MyHerbalife3.Ordering.ServiceProvider.OrderChinaSvc.SkuOrderedAndPurchased { SKU = etoSku.CatalogItem.StockingSKU.Trim(), Category = "ETO", }; var skuList = new List <MyHerbalife3.Ordering.ServiceProvider.OrderChinaSvc.SkuOrderedAndPurchased>(); skuList.Add(skuETO); var totalETOCount = Providers.China.OrderProvider.GetSkuOrderedAndPurchased(ShoppingCart.CountryCode, null, null, null, skuList); var skulimit = Settings.GetRequiredAppSetting("ETOskulimit", string.Empty).Split('|'); if (skulimit.Length > 1 && eligibleSKu.Trim().Equals(skulimit[0]) && totalETOCount.Any(x => x.QuantityPurchased >= Convert.ToInt16(skulimit[1]) && x.SKU == etoSku.CatalogItem.StockingSKU.Trim())) { etoSku.CatalogItem.InventoryList.ToList().ForEach( x => { var val = x.Value as WarehouseInventory_V01; if (val != null) { val.QuantityOnHand = 0; val.QuantityAvailable = 0; val.IsBlocked = true; } }); } } itemList.AddRange( (from p in currentCategory.Products where checkProductAvailability(bShowAllInventory, p) && (from s in p.SKUs where s.IsDisplayable && s.SKU.Contains(eligibleSKu.Trim()) select s).Count() > 0 select new UIProductInfo(currentCategory.ID, getDefaultSKUImagePath(p), p.DisplayName, p.ID, getDefaultSKUPrice(p), sortIndx++)).ToList() ); } else { itemList.AddRange( (from p in currentCategory.Products where checkProductAvailability(bShowAllInventory, p) && (from s in p.SKUs where s.IsDisplayable select s).Count() > 0 select new UIProductInfo(currentCategory.ID, getDefaultSKUImagePath(p), p.DisplayName, p.ID, getDefaultSKUPrice(p), sortIndx++)).ToList() ); } } } }
/// <summary> /// The get all input. /// </summary> /// <returns> /// </returns> /// private List <ShoppingCartItem_V01> getAllInput(List <string> friendlyMessages) { Dictionary <string, SKU_V01> allSKUs = CatalogProvider.GetAllSKU(Locale, base.CurrentWarehouse); SKU_V01 skuV01 = null; friendlyMessages.Clear(); errSKU.Clear(); var products = new List <ShoppingCartItem_V01>(); setError setErrorDelegate = delegate(SkuQty sku, string error, List <string> errors) { sku.Image.Visible = true; sku.HasError = true; if (!errors.Contains(error)) { errors.Add(error); } }; bool bNoItemSelected = true; for (int i = 1; i < NUMITEMS + 1; i++) { string controlID = "SKUBox" + i; var ctrlSKU = tblSKU.FindControl(controlID) as TextBox; var ctrlQty = tblSKU.FindControl("QuantityBox" + i) as TextBox; var ctrlError = tblSKU.FindControl("imgError" + i) as Image; string strSKU = ctrlSKU.Text.Trim(); string strQty = ctrlQty.Text; int qty; int.TryParse(strQty, out qty); if (!string.IsNullOrEmpty(strSKU) && qty != 0) { strSKU = strSKU.ToUpper(); // If the str has a product. strSKU = strSKU.Split(new char[] { ' ' })[0]; AllSKUS.TryGetValue(strSKU, out skuV01); if (skuV01 == null) { // if not valid setup error setErrorDelegate(new SkuQty(controlID, strSKU, qty, ctrlError, true, true), string.Format((GetLocalResourceObject("NoSKUFound") as string), strSKU), errSKU); } else { if (CheckMaxQuantity(ShoppingCart.CartItems, qty, skuV01, errSKU)) { if (skuList.Any(s => s.SKU == strSKU)) { var skuQty = new SkuQty(controlID, strSKU, qty, ctrlError, true, true); skuList.Add(skuQty); setErrorDelegate(skuQty, string.Format((GetLocalResourceObject("DuplicateSKU") as string), strSKU), errSKU); SkuQty skuToFind = skuList.Find(s => s.SKU == strSKU); if (skuToFind != null) { // this is to prevent dupe one to NOT be added to cart skuToFind.HasError = true; skuToFind.Image.Visible = true; } } else { skuList.Add(new SkuQty(controlID, strSKU, qty, ctrlError, false, false)); } } else { ctrlError.CssClass = ctrlError.CssClass.Replace("hide", string.Empty); } } } else if (!string.IsNullOrEmpty(strSKU) && qty <= 0) { setErrorDelegate(new SkuQty(controlID, strSKU, qty, ctrlError, true, false), String.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "QuantityIncorrect"), strSKU), errSKU); } else { if (strSKU.Length + strQty.Length != 0) { setErrorDelegate(new SkuQty(controlID, strSKU, qty, ctrlError, true, false), GetLocalResourceObject("SKUOrQtyMissing") as string, errSKU); } } if (!string.IsNullOrEmpty(strSKU) || !string.IsNullOrEmpty(strQty)) { bNoItemSelected = false; } } if (bNoItemSelected) { errSKU.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "NoItemsSelected")); } else { try { foreach (SkuQty s in skuList) { // do not need to check at this point if (APFDueProvider.IsAPFSku(s.SKU)) { setErrorDelegate(s, string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "SKUNotAvailable"), s.SKU), errSKU); continue; } AllSKUS.TryGetValue(s.SKU, out skuV01); if (skuV01 != null) { HLRulesManager.Manager.ProcessCatalogItemsForInventory(Locale, this.ShoppingCart, new List <SKU_V01> { skuV01 }); CatalogProvider.GetProductAvailability(skuV01, CurrentWarehouse); int availQty; // check isBlocked first if (IsBlocked(skuV01)) { setErrorDelegate(s, string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "SKUNotAvailable"), s.SKU), errSKU); } else if (!skuV01.IsPurchasable) { setErrorDelegate(s, string.Format(GetLocalResourceObject("SKUCantBePurchased") as string, s.SKU), errSKU); } else if (skuV01.ProductAvailability == ProductAvailabilityType.Unavailable) { setErrorDelegate(s, string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "SKUNotAvailable"), s.SKU), errSKU); } else if (HLConfigManager.Configurations.DOConfiguration.IsChina && ChinaPromotionProvider.GetPCPromoSkus(skuV01.SKU)) { setErrorDelegate(s, string.Format(GetLocalResourceObject("SKUCantBePurchased") as string, s.SKU), errSKU); } else { int backorderCoverage = CheckBackorderCoverage(s.Qty, skuV01, friendlyMessages); if (backorderCoverage == 0) { // out of stock if ((availQty = ShoppingCartProvider.CheckInventory(skuV01.CatalogItem, GetAllQuantities(ShoppingCart.CartItems, s.Qty, s.SKU), CurrentWarehouse)) == 0) { setErrorDelegate(s, string.Format(MyHL_ErrorMessage.OutOfInventory, s.SKU), errSKU); } else if (availQty < GetAllQuantities(ShoppingCart.CartItems, s.Qty, s.SKU)) { setErrorDelegate(s, string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "LessInventory"), s.SKU, availQty), errSKU); HLRulesManager.Manager.PerformBackorderRules(ShoppingCart, skuV01.CatalogItem); IEnumerable <string> ruleResultMessages = from r in ShoppingCart.RuleResults where r.Result == RulesResult.Failure && r.RuleName == "Back Order" select r.Messages[0]; if (null != ruleResultMessages && ruleResultMessages.Count() > 0) { errSKU.Add(ruleResultMessages.First()); ShoppingCart.RuleResults.Clear(); } } } } } } //if (errSKU.Count == 0) { products.AddRange((from c in skuList where c.HasError == false select new ShoppingCartItem_V01(0, c.SKU, c.Qty, DateTime.Now)).ToList()); } } catch (Exception ex) { LoggerHelper.Error(string.Format("getAllInput error:" + ex)); } } return(products); }