private void RemoveItemsAdded(ref ShoppingCart_V02 cart) { var hlCart = cart as MyHLShoppingCart; ShoppingCartItemList cartItems = new ShoppingCartItemList(); cartItems.AddRange(hlCart.CartItems); foreach (ShoppingCartItem_V01 item in hlCart.CurrentItems) { if (cartItems.Exists(i => i.SKU == item.SKU && i.Quantity >= item.Quantity)) { cartItems.FirstOrDefault(i => i.SKU == item.SKU).Quantity -= item.Quantity; if (cartItems.FirstOrDefault(i => i.SKU == item.SKU).Quantity < 1) { cartItems.Remove(cartItems.FirstOrDefault(i => i.SKU == item.SKU)); } } } // Clear Cart and Re Add initial items hlCart.DeleteItemsFromCart((from i in hlCart.CartItems select i.SKU).ToList <string>()); hlCart.AddItemsToCart(cartItems, true); cart = hlCart; }
private int getPTypeSKUCount(ShoppingCartItemList cartItems, ShoppingCartItem_V01 currentItem) { int count = 0; SKU_V01 skuV01; Dictionary <string, SKU_V01> allSKUs = CatalogProvider.GetAllSKU(this.Locale); foreach (ShoppingCartItem_V01 item in cartItems) { if (allSKUs.TryGetValue(item.SKU, out skuV01)) { if (skuV01.CatalogItem != null && skuV01.CatalogItem.ProductType == ProductType.Product) { count += item.Quantity; } } } if (currentItem != null) // include current item being added { if (allSKUs.TryGetValue(currentItem.SKU, out skuV01)) { if (skuV01.CatalogItem != null && skuV01.CatalogItem.ProductType == ProductType.Product) { count += currentItem.Quantity; } } } return(count); }
public void ExceedGroupLimitAndIndivualLimit_TestMethod() { var cartItems = new ShoppingCartItemList(); cartItems.Add(new ShoppingCartItem_V01 { SKU = "0120", Quantity = 9 }); var cartItemsBeingAdded = new ShoppingCartItemList(); cartItemsBeingAdded.Add(new ShoppingCartItem_V01 { SKU = "0120", Quantity = 1 }); // FO cartItemsBeingAdded.Add(new ShoppingCartItem_V01 { SKU = "0118", Quantity = 91 }); // FO cartItemsBeingAdded.Add(new ShoppingCartItem_V01 { SKU = "1158", Quantity = 11 }); // NFO MyHLShoppingCart cart = MyHLShoppingCartGenerator.GetBasicShoppingCart("staff", "ja-JP", "30", "SAG", cartItems, OrderCategoryType.RSO); cart.ItemsBeingAdded = cartItemsBeingAdded; MyHerbalife3.Ordering.Rules.PurchaseRestriction.JP.PurchaseRestrictionRules rules = new MyHerbalife3.Ordering.Rules.PurchaseRestriction.JP.PurchaseRestrictionRules(); rules.HandleCartItemsBeingAdded(cart, new ShoppingCartRuleResult(), MockPurchaseRestrictionInfo()); }
public void SKU0106_OverLimit_TestMethod1() { var cartItems = new ShoppingCartItemList(); cartItems.Add(new ShoppingCartItem_V01 { SKU = "0120", Quantity = 1 }); cartItems.Add(new ShoppingCartItem_V01 { SKU = "0106", Quantity = 6 }); //NFO var cartItemsBeingAdded = new ShoppingCartItemList(); cartItemsBeingAdded.Add(new ShoppingCartItem_V01 { SKU = "0106", Quantity = 4 }); MyHLShoppingCart cart = MyHLShoppingCartGenerator.GetBasicShoppingCart("staff", "ja-JP", "XX", "XX", cartItems, OrderCategoryType.RSO); cart.ItemsBeingAdded = cartItemsBeingAdded; MyHerbalife3.Ordering.Rules.PurchaseRestriction.JP.PurchaseRestrictionRules rules = new MyHerbalife3.Ordering.Rules.PurchaseRestriction.JP.PurchaseRestrictionRules(); rules.HandleCartItemsBeingAdded(cart, new ShoppingCartRuleResult(), MockPurchaseRestrictionInfo()); }
public ShoppingCartItemList Get(int customerId) { IEnumerable <ShoppingCartItem> shoppingCartItems = _shoppingCartItemService.GetAllCartItems(customerId); ShoppingCartItemList shoppingCartItemList = shoppingCartItems.ToModels(); return(shoppingCartItemList); }
public static bool IsAPFSkuPresent(ShoppingCartItemList cartItems) { var sku = from s in GetAPFSkuList() from c in cartItems where s == c.SKU.Trim() select s; return(sku.Count() != 0); }
public static List <string> GetAPFSkusFromCart(ShoppingCartItemList cartItems) { var sku = from s in GetAPFSkuList() from c in cartItems where s == c.SKU.Trim() select s; return(sku.ToList()); }
/// <summary> /// Adds to cart. /// </summary> /// <param name="cart">The cart.</param> /// <param name="item">The item.</param> internal static void PrepareAddToCart(MyHLShoppingCart cart, ShoppingCartItem_V01 item) { var list = new ShoppingCartItemList { item }; //cart.CartItems.Add(item); cart.CurrentItems = list; }
internal static ShoppingCart_V02 GetShoppingCart(int cartID, DateTime lastUpdated, string locale, int deliveryOptionID, OrderCategoryType orderCategory, DeliveryOptionType deliveryOption, int shippingAddressID, string distributorID, string freightCode, string orderSubType) { var itemList = new ShoppingCartItemList { new ShoppingCartItem_V01() }; var orderDetail = new CustomerOrderDetail(); return(new ShoppingCart_V02(cartID, lastUpdated, locale, deliveryOptionID, orderCategory, deliveryOption, shippingAddressID, itemList, distributorID, freightCode, orderSubType, orderDetail)); }
public static ShoppingCartItemList GetDistributorShoppingCartItemList(List <string> skus) { Random random = new Random(); var items = new ShoppingCartItemList(); items.AddRange(from s in skus select new ShoppingCartItem_V01 { SKU = s, Quantity = random.Next(1, 10) }); return(items); }
public void addItem(Product product, int quantity) { ShoppingCartItem cartItem = new ShoppingCartItem(); cartItem.setProduct(product); cartItem.setQuantity(quantity); ShoppingCartItemList.Add(cartItem); TotalAmount += product.getPrice() * quantity; }
internal static ShoppingCart_V02 GetShoppingCart(int cartID, DateTime lastUpdated, string locale, int deliveryOptionID, MyHerbalife3.Ordering.ServiceProvider.CatalogSvc.OrderCategoryType orderCategory, MyHerbalife3.Ordering.ServiceProvider.CatalogSvc.DeliveryOptionType deliveryOption, int shippingAddressID, string distributorID, string freightCode, string orderSubType) { var itemList = new ShoppingCartItemList { new ShoppingCartItem_V01() }; var orderDetail = new CustomerOrderDetail(); return(new ShoppingCart_V02() { ShoppingCartID = cartID, LastUpdated = lastUpdated, Locale = locale, DeliveryOptionID = deliveryOptionID, OrderCategory = orderCategory, DeliveryOption = deliveryOption, ShippingAddressID = shippingAddressID, CartItems = itemList, DistributorID = distributorID, FreightCode = freightCode, OrderSubType = orderSubType, CustomerOrderDetail = orderDetail }); }
public static ShoppingCartItemList ToModels(this IEnumerable <ShoppingCartItem> shoppingCartItems) { ShoppingCartItemList shoppingCartItemList = new ShoppingCartItemList(); foreach (ShoppingCartItem shoppingCartItem in shoppingCartItems) { ShoppingCartItemModel shoppingCartItemModel = shoppingCartItem.ToModel(); shoppingCartItemList.ShoppingCartItems.Add(shoppingCartItemModel); shoppingCartItemList.TotalPrice += shoppingCartItemModel.CartItemPrice; } return(shoppingCartItemList); }
public static void UpdateAPFDue(string distributorID, DateTime due, ShoppingCartItemList cartItems) { if (IsAPFSkuPresent(cartItems)) { using (var proxy = ServiceClientProvider.GetCatalogServiceProxy()) { var response = proxy.UpdateAPFDue(new UpdateAPFDueRequest(new UpdateAPFPaidRequest_V01 { DistributorID = distributorID, DueDate = due })).UpdateAPFDueResult as UpdateAPFPaidResponse_V01; if (response.Status == ServiceResponseStatusType.Success) { saveAPFDuePaidToCache(getCacheKey(distributorID), true); } } } }
public bool IsPreordering(ShoppingCartItemList cart, string wareHousecode) { return Providers.CatalogProvider.IsPreordering(cart, wareHousecode); }
public ShoppingCartRuleResult HandleCartItemsBeingAdded(MyHLShoppingCart cart, ShoppingCartRuleResult Result, List <PurchaseRestrictionInfo> allLimits) { var error1 = defaultError1(); var error2 = defaultError2(); Func <ShoppingCartItemList, ShoppingCartItem_V01, int> sumQuantity = delegate(ShoppingCartItemList itemsInCart, ShoppingCartItem_V01 itemToAdd) { return(itemsInCart.Find(i => i.SKU.Equals(itemToAdd.SKU)) == null ? itemToAdd.Quantity : itemsInCart.Find(i => i.SKU.Equals(itemToAdd.SKU)).Quantity + itemToAdd.Quantity); }; // sum quantity in cart and quantity to add for every sku being added ShoppingCartItemList newItemsToAdd = new ShoppingCartItemList(); Array.ForEach(cart.ItemsBeingAdded.ToArray(), a => newItemsToAdd.Add(new ShoppingCartItem_V01 { SKU = a.SKU, Quantity = sumQuantity(cart.CartItems, a) })); List <string> errorList = new List <string>(); List <string> itemsToRemove = new List <string>(); // non formula one var nonFormulaOneLimits = allLimits.Where(f => !f.Group.Equals(groupFormulaOne)); if (nonFormulaOneLimits != null && nonFormulaOneLimits.Count() > 0) { var itemsCannotAdd = (from a in nonFormulaOneLimits.First().SKUInfoList from b in newItemsToAdd where a.SKU == b.SKU && b.Quantity > a.QuantityAllow select new { SKU = b, Qty = a.QuantityAllow } ); // set error message errorList.AddRange(from c in itemsCannotAdd select string.Format(error1.ToString(), c.SKU.SKU, 100, c.Qty)); // remove items can't be added itemsToRemove.AddRange(from c in itemsCannotAdd select c.SKU.SKU); newItemsToAdd.RemoveAll(s => itemsCannotAdd.Select(a => a.SKU.SKU).Contains(s.SKU)); } if (newItemsToAdd.Count() > 0) { // formula one var formulaOneLimits = allLimits.Where(l => l.Group.Equals(groupFormulaOne)); if (formulaOneLimits != null && formulaOneLimits.Count() > 0) { var formulaOneSKUs = formulaOneLimits.First().SKUInfoList; var formulaOneToAdd = (from a in formulaOneSKUs from b in newItemsToAdd where a.SKU == b.SKU select new { SKU = b, Qty = a.QuantityAllow } ); var qtyFormulaOneInCartNotBeingAdded = (from a in cart.CartItems from b in formulaOneSKUs where a.SKU == b.SKU select a).Except (from c in formulaOneToAdd from d in cart.CartItems where c.SKU.SKU == d.SKU select d).ToList().Sum(x => x.Quantity); int formulaOneSKUsAllowQty = formulaOneSKUs.Count() > 0 ? formulaOneSKUs.First().QuantityAllow : 0; // exceed formula-1 group limit if (formulaOneToAdd.Sum(f => f.SKU.Quantity) + qtyFormulaOneInCartNotBeingAdded > formulaOneSKUs.First().QuantityAllow) { errorList.Add( string.Format( error2.ToString(), string.Join("と", formulaOneToAdd.Select(x => x.SKU.SKU)), 200, formulaOneSKUs.First().QuantityAllow) ); itemsToRemove.AddRange(from c in formulaOneToAdd select c.SKU.SKU); } } } errorList = errorList.Distinct().ToList(); if (errorList.Count > 0) { Result.Result = RulesResult.Failure; Result.RuleName = "PurchaseRestriction Rules"; Array.ForEach(errorList.ToArray(), a => Result.AddMessage(a)); cart.RuleResults.Add(Result); cart.ItemsBeingAdded.RemoveAll(s => itemsToRemove.Select(a => a).Contains(s.SKU)); } return(Result); }
/// <summary> /// Gets the basic shopping cart. /// </summary> /// <param name="distributorId">The distributor id.</param> /// <param name="locale">The locale.</param> /// <param name="freightCode">The freight code.</param> /// <param name="wareHouseCode">The ware house code.</param> /// <param name="calculate">if set to <c>true</c> [calculate].</param> /// <param name="totals">The totals.</param> /// <param name="shoppingCartItem">The shopping cart item.</param> /// <param name="orderCType">Type of the order C.</param> /// <returns></returns> internal static MyHLShoppingCart GetBasicShoppingCart(string distributorId, string locale, string freightCode, string wareHouseCode, bool calculate, OrderTotals_V01 totals, List <DistributorShoppingCartItem> shoppingCartItem, OrderCategoryType orderCType) { if (string.IsNullOrEmpty(locale)) { locale = "en-US"; } if (string.IsNullOrEmpty(freightCode)) { freightCode = HLConfigManager.CurrentPlatformConfigs[locale].ShoppingCartConfiguration.DefaultFreightCode; } if (string.IsNullOrEmpty(wareHouseCode)) { wareHouseCode = HLConfigManager.CurrentPlatformConfigs[locale].ShoppingCartConfiguration.DefaultWarehouse; } var cartItemList = new ShoppingCartItemList(); cartItemList.AddRange(shoppingCartItem.Select(i => new ShoppingCartItem_V01 { ID = i.ID, MinQuantity = i.MinQuantity, PartialBackordered = i.PartialBackordered, Quantity = i.Quantity, SKU = i.SKU, Updated = i.Updated })); var shoppingCart = new MyHLShoppingCart { Locale = locale, ShoppingCartItems = shoppingCartItem, CartItems = cartItemList, DistributorID = string.IsNullOrEmpty(distributorId) ? "webtest1" : distributorId, FreightCode = freightCode, CurrentItems = cartItemList, DeliveryInfo = new ShippingInfo { FreightCode = freightCode, WarehouseCode = wareHouseCode, Option = DeliveryOptionType.Shipping, Address = new ShippingAddress_V02 { FirstName = string.Empty, LastName = string.Empty, Recipient = string.Empty } }, CountryCode = locale.Substring(3), OrderCategory = orderCType }; // Calculate totals. if (calculate) { shoppingCart.Totals = shoppingCart.Calculate(); } else { // Use dummy totals shoppingCart.Totals = totals ?? new OrderTotals_V01 { AmountDue = 1000M, BalanceAmount = 900M, DiscountPercentage = 50M, VolumePoints = 1000 }; } // Rules results shoppingCart.RuleResults = new List <ShoppingCartRuleResult>(); return(shoppingCart); }
internal static MyHLShoppingCart GetBasicShoppingCart(string distributorId, string locale, string freightCode, string wareHouseCode, ShoppingCartItemList CartItem, MyHerbalife3.Ordering.ServiceProvider.CatalogSvc.OrderCategoryType OrderCType) { if (string.IsNullOrEmpty(locale)) { locale = "en-US"; } if (string.IsNullOrEmpty(freightCode)) { freightCode = HLConfigManager.CurrentPlatformConfigs[locale].ShoppingCartConfiguration.DefaultFreightCode; } if (string.IsNullOrEmpty(wareHouseCode)) { wareHouseCode = HLConfigManager.CurrentPlatformConfigs[locale].ShoppingCartConfiguration.DefaultWarehouse; } var shoppingCart = new MyHLShoppingCart { Locale = locale, ShoppingCartItems = (from c in CartItem select new DistributorShoppingCartItem { SKU = c.SKU, Quantity = c.Quantity }).ToList(), CartItems = CartItem, DistributorID = string.IsNullOrEmpty(distributorId) ? "webtest1" : distributorId, FreightCode = freightCode, CurrentItems = CartItem, DeliveryInfo = new ShippingInfo { FreightCode = freightCode, WarehouseCode = wareHouseCode, Option = ServiceProvider.ShippingSvc.DeliveryOptionType.Shipping, Address = new ShippingAddress_V02 { FirstName = string.Empty, LastName = string.Empty, Recipient = string.Empty } }, CountryCode = locale.Substring(3), OrderCategory = OrderCType }; shoppingCart.Totals = new OrderTotals_V01 { AmountDue = 1000M, BalanceAmount = 900M, DiscountPercentage = 50M, VolumePoints = 1000 }; // Rules results shoppingCart.RuleResults = new List <ShoppingCartRuleResult>(); return(shoppingCart); }
private ShoppingCartRuleResult CartItemBeingDeletedRuleHandler(ShoppingCart_V01 cart, ShoppingCartRuleResult result, string level) { if (APFDueProvider.IsAPFDueAndNotPaid(cart.DistributorID, Locale) && HLConfigManager.Configurations.APFConfiguration.StandaloneAPFOnlyAllowed) { result.Result = RulesResult.Failure; result.AddMessage( HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "CompleteAPFPurchase") as string); var sku = APFDueProvider.GetAPFSku(); SetApfRuleResponse(result, ApfAction.None, sku, "ApfRule", TypeOfApf.StandaloneAPFOnlyAllowed, "CompleteAPFPurchase"); cart.RuleResults.Add(result); return(result); } //Deleting is a little different than Inserting, because delete handles multiple skus while insert only does one //so we can use the cart.CurrentItems to control this. Anything the rule says to not delete, we remove from the CurrentItems //Delete post-rule will only delete what is left in there bool isStandaloneAPF = APFDueProvider.hasOnlyAPFSku(cart.CartItems, Locale); var toRemove = new List <ShoppingCartItem_V01>(); var hlCart = cart as MyHLShoppingCart; if (null != hlCart) { foreach (ShoppingCartItem_V01 item in cart.CurrentItems) { if (APFDueProvider.IsAPFSku(item.SKU)) { if ( !APFDueProvider.CanRemoveAPF(cart.DistributorID, Thread.CurrentThread.CurrentCulture.Name, level)) { result.Result = RulesResult.Failure; result.AddMessage( HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "CannotRemoveAPFSku") as string); var sku = APFDueProvider.GetAPFSku(); SetApfRuleResponse(result, ApfAction.None, sku, "ApfRule", TypeOfApf.StandaloneAPFOnlyAllowed, "CannotRemoveAPFSku"); cart.RuleResults.Add(result); } else { if (APFDueProvider.IsAPFDueAndNotPaid(cart.DistributorID, Locale)) { var originalItem = (from c in cart.CartItems where c.SKU == cart.CurrentItems[0].SKU select c).ToList(); int requiredQuantity = APFDueProvider.APFQuantityDue(cart.DistributorID, Locale); if (level == "SP") { item.Quantity = requiredQuantity; result.Result = RulesResult.Recalc; result.AddMessage( HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "RequiredAPFLeftInCart") as string); var sku = APFDueProvider.GetAPFSku(); SetApfRuleResponse(result, ApfAction.None, sku, "ApfRule", TypeOfApf.StandaloneAPFOnlyAllowed, "RequiredAPFLeftInCart"); cart.RuleResults.Add(result); //toRemove.Add(item); cart.APFEdited = false; return(result); } //Add for ChinaDO if (HLConfigManager.Configurations.APFConfiguration.CantDSRemoveAPF) { result.Result = RulesResult.Recalc; result.AddMessage( HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "RequiredAPFLeftInCart") as string); var sku = APFDueProvider.GetAPFSku(); SetApfRuleResponse(result, ApfAction.None, sku, "ApfRule", TypeOfApf.StandaloneAPFOnlyAllowed, "RequiredAPFLeftInCart"); cart.RuleResults.Add(result); //toRemove.Add(item); cart.APFEdited = false; return(result); } } cart.APFEdited = true; toRemove.Add(item); // added } } else { toRemove.Add(item); // added } } //if (toRemove.Count > 0) //{ // cart.CurrentItems.Remove(toRemove[0]); //} var remainingItems = (from c in cart.CartItems where !toRemove.Any(x => x.SKU == c.SKU) select c).ToList(); //List<ShoppingCartItem_V01> remainingItems = (from c in cart.CartItems where c.SKU != cart.CurrentItems[0].SKU select c).ToList(); var mags = CartHasOnlyTodaysMagazine(remainingItems); if (mags.Count > 0) { foreach (ShoppingCartItem_V01 item in mags) { (cart as MyHLShoppingCart).DeleteTodayMagazine(item.SKU); remainingItems.Remove(item); if (!cart.CurrentItems.Exists(c => c.SKU == item.SKU)) { cart.CurrentItems.Add(item); } } result.Result = RulesResult.Failure; result.AddMessage( HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "NoTodayMagazineWithStandalonAPF") as string); var sku = APFDueProvider.GetAPFSku(); SetApfRuleResponse(result, ApfAction.None, sku, "ApfRule", TypeOfApf.StandaloneAPFOnlyAllowed, "NoTodayMagazineWithStandalonAPF"); cart.RuleResults.Add(result); } // added if (remainingItems.Count > 0) { var list = new ShoppingCartItemList(); list.AddRange(remainingItems); isStandaloneAPF = APFDueProvider.hasOnlyAPFSku(list, Locale); if (isStandaloneAPF) { SetAPFDeliveryOption(hlCart); } else { if (APFDueProvider.IsAPFSkuPresent(cart.CurrentItems)) { SetNonStandAloneAPFDeliveryOption(hlCart); } } } else { SetNonStandAloneAPFDeliveryOption(hlCart); } } //if((from c in cart.CurrentItems where APFDueProvider.IsAPFSku(c.SKU) select c).Count() >0) //{ // if (isStandaloneAPF) // { // SetAPFDeliveryOption(hlCart); // } //} return(result); }
private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result) { if (cart == null) { return(Result); } if (reason == ShoppingCartRuleReason.CartItemsBeingAdded) { string sku = cart.CurrentItems[0].SKU.Trim(); var allowed = new List <string>(); if (_IBPAllowedSubTypes.TryGetValue(sku, out allowed)) { string orderSubType = cart.OrderSubType; if (string.IsNullOrEmpty(cart.OrderSubType)) { var purchasingLimits = PurchasingLimitProvider.GetCurrentPurchasingLimits(cart.DistributorID); if (null != purchasingLimits) { orderSubType = purchasingLimits.PurchaseSubType; } } if (!allowed.Contains(orderSubType)) { Result.Result = RulesResult.Failure; var errorMessage = HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform), "SKU" + sku + "Limitations") ?? string.Format("SKU {0} Limitations", sku); Result.AddMessage(string.Format(errorMessage.ToString(), cart.CurrentItems[0].SKU)); cart.RuleResults.Add(Result); } } if (cart.CurrentItems[0].SKU == HLConfigManager.Configurations.DOConfiguration.TodayMagazineSku) { var catItems = CatalogProvider.GetCatalogItems( (from c in cart.CartItems select c.SKU.Trim()).ToList <string>(), Country); if (catItems != null) { if (!catItems.Any(c => c.Value.ProductType == ProductType.Product)) { Result.Result = RulesResult.Failure; Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "AddProductFirst") .ToString(), cart.CurrentItems[0].SKU)); cart.RuleResults.Add(Result); } } } } else if (reason == ShoppingCartRuleReason.CartItemsAdded) { var tempShoppingCartList = new ShoppingCartItemList(); tempShoppingCartList.AddRange(from c in cart.CartItems select new ShoppingCartItem_V01(c.ID, c.SKU, c.Quantity, c.Updated)); var item = tempShoppingCartList.Where(i => i.SKU == cart.CurrentItems[0].SKU); if (null != item && item.Count() > 0) { var itemFirst = item.First(); itemFirst.Quantity += cart.CurrentItems[0].Quantity; } else { tempShoppingCartList.Add(cart.CurrentItems[0]); } } else if (reason == ShoppingCartRuleReason.CartCalculated) { string orderSubType = cart.OrderSubType; if (string.IsNullOrEmpty(cart.OrderSubType)) { var purchasingLimits = PurchasingLimitProvider.GetCurrentPurchasingLimits(cart.DistributorID); if (null != purchasingLimits) { orderSubType = purchasingLimits.PurchaseSubType; } } var myhlCart = cart as MyHLShoppingCart; if (myhlCart != null) { var found = (from a in _IBPAllowedSubTypes.Keys.ToList() from s in myhlCart.ShoppingCartItems where a == s.SKU select a); if (found.Count() > 0) { var skuToDelete = new List <string>(); foreach (string sku in found) { var allowed = new List <string>(); if (_IBPAllowedSubTypes.TryGetValue(sku, out allowed)) { if (!allowed.Contains(orderSubType)) { skuToDelete.Add(sku); } } } if (skuToDelete.Count() > 0) { myhlCart.DeleteItemsFromCart(skuToDelete); foreach (string sku in skuToDelete) { Result.Result = RulesResult.Failure; Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "SKU" + sku + "Limitations").ToString(), sku)); cart.RuleResults.Add(Result); } } } } } return(Result); }