private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart,
                                                    ShoppingCartRuleReason reason,
                                                    ShoppingCartRuleResult Result)
        {
            if (reason == ShoppingCartRuleReason.CartItemsBeingAdded)
            {
                bool bEventTicket = isEventTicket(cart.DistributorID, Locale);
                var  thisCart     = cart as MyHLShoppingCart;
                if (null != thisCart)
                {
                    //Kiosk items must have inventory
                    string             sku                = thisCart.CurrentItems[0].SKU;
                    var                catItem            = CatalogProvider.GetCatalogItem(sku, Country);
                    WarehouseInventory warehouseInventory = null;

                    var isSplitted = false;

                    if (thisCart.DeliveryInfo != null && thisCart.DeliveryInfo.Option == ServiceProvider.ShippingSvc.DeliveryOptionType.Shipping &&
                        HLConfigManager.Configurations.DOConfiguration.WhCodesForSplit.Contains(thisCart.DeliveryInfo.WarehouseCode))
                    {
                        //split order scenario
                        ShoppingCartProvider.CheckInventory(catItem, thisCart.CurrentItems[0].Quantity, thisCart.DeliveryInfo.WarehouseCode, thisCart.DeliveryInfo.FreightCode, ref isSplitted);
                    }


                    if (!isSplitted && null != thisCart.DeliveryInfo && !string.IsNullOrEmpty(thisCart.DeliveryInfo.WarehouseCode) && !bEventTicket && !isNonInventoryItem(sku))
                    {
                        catItem.InventoryList.TryGetValue(thisCart.DeliveryInfo.WarehouseCode, out warehouseInventory);
                        if ((warehouseInventory != null && (warehouseInventory as WarehouseInventory_V01).QuantityAvailable <= 0) || warehouseInventory == null)
                        {
                            Result.AddMessage(string.Format(HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "BackOrderItem").ToString(), sku));
                            Result.Result = RulesResult.Failure;
                            cart.RuleResults.Add(Result);
                        }
                        else
                        {
                            int availQuantity = InventoryHelper.CheckInventory(thisCart, thisCart.CurrentItems[0].Quantity, catItem, thisCart.DeliveryInfo.WarehouseCode);
                            if (availQuantity - thisCart.CurrentItems[0].Quantity < 0)
                            {
                                Result.AddMessage(string.Format(HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "OutOfInventory").ToString(), sku));
                                Result.Result = RulesResult.Failure;
                                cart.RuleResults.Add(Result);
                            }
                        }
                    }
                }
            }

            return(Result);
        }
Beispiel #2
0
 public void CheckInventory(ShoppingCart_V02 shoppingCart, int quantity, SKU_V01 sku, string warehouse, ref int availQuantity)
 {
     availQuantity = InventoryHelper.CheckInventory(shoppingCart, quantity, sku.CatalogItem, warehouse);
 }