public void findCrossSell(List <ShoppingCartItem_V01> products) { var crossSellList = new List <CrossSellInfo>(); foreach (var cartItem in products) { var item = ShoppingCart.ShoppingCartItems.Find(s => s.SKU == cartItem.SKU); if (item != null) { if (item.ProdInfo == null || item.ParentCat == null || item.ProdInfo.CrossSellProducts == null) { continue; } foreach (var cat in item.ProdInfo.CrossSellProducts.Keys) { crossSellList.AddRange(from a in item.ProdInfo.CrossSellProducts[cat] select new CrossSellInfo(cat, a)); } } } if (crossSellList.Count > 0) { CrossSellInfo candidate = null; foreach (var c in crossSellList) { if (ProductDetail.ShouldSelectThisCrossSell(c.Product, ShoppingCart, Session[ProductDetail.LAST_SEEN_PRODUCT_SESSION_EKY] as CrossSellInfo, Session[ ProductDetail. LAST_SEEN_CROSS_SELL_PRODUCT_SESSION_EKY] as CrossSellInfo)) { if (!ProductDetail.IfOutOfStock(c.Product, AllSKUS)) { candidate = c; break; } } } // if nothing found if (candidate == null) { candidate = ProductDetail.SelectCrossSellFromPreviousDisplayOrCrssSellList(ShoppingCart, crossSellList, Session[ ProductDetail. LAST_SEEN_CROSS_SELL_PRODUCT_SESSION_EKY ] as CrossSellInfo, AllSKUS); if (candidate != null && ProductDetail.IfOutOfStock(candidate.Product, AllSKUS)) { candidate = null; } } if (candidate != null) { Session[ProductDetail.LAST_SEEN_CROSS_SELL_PRODUCT_SESSION_EKY] = candidate; // fire event CrossSellFound(this, new CrossSellEventArgs(candidate)); return; } } //findCrossSell(); NoCrossSellFound(this, null); }