private ShoppingCartRuleResult reportError(MyHLShoppingCart cart, ShoppingCartItem_V01 item, ShoppingCartRuleResult Result)
 {
     Result.Result = RulesResult.Failure;
     if (cart.CartItems.Exists(i => i.SKU == item.SKU))
     {
         ///The quantity of the item SKU:{0} can not be increased by {1} because it exceeds your Purchasing Limit.
         Result.Messages.Add(
             string.Format(
                 HttpContext.GetGlobalResourceObject(
                     string.Format("{0}_Rules", HLConfigManager.Platform),
                     "DiscountedRetailExceedsByIncreasingQuantity").ToString(),
                 item.SKU, item.Quantity));
     }
     else
     {
         ///Item SKU:{0} has not been added to the cart since by adding that into the cart, you exceeded your Purchasing Limit.
         Result.Messages.Add(
             string.Format(
                 HttpContext.GetGlobalResourceObject(
                     string.Format("{0}_Rules", HLConfigManager.Platform),
                     "DiscountedRetailExceeds").ToString(), item.SKU));
     }
     cart.RuleResults.Add(Result);
     return(Result);
 }
        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);
        }
        private GetDiscontinuedSkuParam GetDiscontinuedSkuParamMock()
        {
            List <ShoppingCartItem_V01> DiscontinuedItems = new List <ShoppingCartItem_V01>();
            ShoppingCartItem_V01        item = new ShoppingCartItem_V01
            {
                SKU                = "1318",
                IsPromo            = false,
                Quantity           = 1,
                PartialBackordered = false,
                Updated            = DateTime.Now,
            };

            ShoppingCartItem_V01 item1 = new ShoppingCartItem_V01
            {
                SKU                = "9143",
                IsPromo            = true,
                Quantity           = 1,
                PartialBackordered = false,
                Updated            = DateTime.Now,
            };

            DiscontinuedItems.Add(item);
            DiscontinuedItems.Add(item1);

            GetDiscontinuedSkuParam param = new GetDiscontinuedSkuParam
            {
                DistributorId           = "CN640521",
                Locale                  = "zh-CN",
                ShoppingCartItemToCheck = DiscontinuedItems
            };

            return(param);
        }
Esempio n. 4
0
 public List <ShoppingCartRuleResult> processCart(MyHLShoppingCart cart,
                                                  ShoppingCartItem_V01 item,
                                                  ShoppingCartRuleReason reason)
 {
     return(Providers.ShoppingCartProvider.processCart(cart,
                                                       item,
                                                       reason));
 }
Esempio n. 5
0
        /// <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;
        }
Esempio n. 6
0
        private void checkPerOrderLimit(MyHLShoppingCart myCart, ShoppingCartRuleResult Result)
        {
            ShoppingCartItem_V01 backupItem = null;
            var existingItem =
                myCart.ShoppingCartItems.FirstOrDefault(p => p.SKU == myCart.CurrentItems[0].SKU);

            if (null != existingItem)
            {
                backupItem = new ShoppingCartItem_V01(existingItem.ID, existingItem.SKU,
                                                      existingItem.Quantity,
                                                      DateTime.Now, existingItem.MinQuantity);
            }

            myCart.AddItemsToCart(myCart.CurrentItems, true);

            var Totals = myCart.Calculate() as OrderTotals_V01;

            if (Totals != null && Totals.AmountDue > MaxAmount)
            {
                var globalResourceObject =
                    HttpContext.GetGlobalResourceObject(
                        string.Format("{0}_Rules", HLConfigManager.Platform), "AmountLimitExceeds");
                if (globalResourceObject != null)
                {
                    Result.AddMessage(
                        string.Format(
                            globalResourceObject
                            .ToString(), MaxAmount.ToString()));
                }
                globalResourceObject =
                    HttpContext.GetGlobalResourceObject(
                        string.Format("{0}_Rules", HLConfigManager.Platform),
                        "DisgardCommonMessage");
                if (globalResourceObject != null)
                {
                    Result.AddMessage(globalResourceObject.ToString());
                }
                Result.Result = RulesResult.Failure;
            }

            myCart.DeleteItemsFromCart(new List <string> {
                myCart.CurrentItems[0].SKU
            }, true);

            if (backupItem != null)
            {
                myCart.AddItemsToCart(new List <ShoppingCartItem_V01> {
                    backupItem
                }, true);
                myCart.Calculate();
            }
        }
        private List <ShoppingCartItem_V01> GetDiscontinuedSkuPromoMock()
        {
            List <ShoppingCartItem_V01> itemList = new List <ShoppingCartItem_V01>();
            ShoppingCartItem_V01        item     = new ShoppingCartItem_V01
            {
                SKU                = "9143",
                IsPromo            = true,
                MinQuantity        = 1,
                PartialBackordered = false,
                Quantity           = 1,
                Updated            = DateTime.Now
            };

            itemList.Add(item);
            return(itemList);
        }
        private ShoppingCartItemList GetCartItems(int mode)
        {
            ShoppingCartItemList cartItemList = new ShoppingCartItemList();

            if (mode == 0)
            {
                ShoppingCartItem_V01 item = new ShoppingCartItem_V01
                {
                    SKU         = "9909",
                    IsPromo     = false,
                    MinQuantity = 0,
                    Quantity    = 1,
                    Updated     = DateTime.Now
                };
                cartItemList.Add(item);
            }

            if (mode == 1)
            {
                ShoppingCartItem_V01 item2 = new ShoppingCartItem_V01
                {
                    SKU         = "1316",
                    IsPromo     = false,
                    MinQuantity = 0,
                    Quantity    = 1,
                    Updated     = DateTime.Now
                };
                cartItemList.Add(item2);
            }
            if (mode == 3)
            {
                ShoppingCartItem_V01 item3 = new ShoppingCartItem_V01
                {
                    SKU         = "9143",
                    IsPromo     = true,
                    MinQuantity = 0,
                    Quantity    = 1,
                    Updated     = DateTime.Now
                };
                cartItemList.Add(item3);
            }


            return(cartItemList);
        }
        /// <summary>
        /// The get customer cart items.
        /// </summary>
        /// <param name="shoppingCartID">
        /// The shopping cart id.
        /// </param>
        /// <param name="items">
        /// The items.
        /// </param>
        /// <returns>
        /// List of shopping cart items
        /// </returns>
        private static List <ShoppingCartItem_V01> GetCustomerCartItems(int shoppingCartID, ServiceProvider.CustomerOrderSvc.OrderItems items)
        {
            var lstSkus = new List <ShoppingCartItem_V01>();

            for (int i = 0; i < items.Count; i++)
            {
                var cartItem = new ShoppingCartItem_V01()
                {
                    ID          = shoppingCartID,
                    SKU         = items[i].SKU,
                    Quantity    = items[i].Quantity,
                    Updated     = DateTime.Now,
                    MinQuantity = items[i].Quantity
                };
                lstSkus.Add(cartItem);
            }

            return(lstSkus);
        }
 private ShoppingCartRuleResult reportError(MyHLShoppingCart cart, ShoppingCartItem_V01 item, ShoppingCartRuleResult Result)
 {
     if (cart.CartItems.Exists(i => i.SKU == item.SKU))
     {
         Result.AddMessage(
             string.Format(
                 HttpContext.GetGlobalResourceObject(
                     string.Format("{0}_Rules", HLConfigManager.Platform),
                     "DiscountedRetailExceedsByIncreasingQuantity").ToString(),
                 item.SKU, item.Quantity));
     }
     else
     {
         Result.AddMessage(
             string.Format(
                 HttpContext.GetGlobalResourceObject(
                     string.Format("{0}_Rules", HLConfigManager.Platform),
                     "DiscountedRetailExceeds").ToString(), item.SKU));
     }
     cart.RuleResults.Add(Result);
     return(Result);
 }
Esempio n. 11
0
        private ShoppingCartItem_V01 GetApfSku(List <ShoppingCartItem_V01> cartItems, string locale, string level)
        {
            ShoppingCartItem_V01 sku = null;
            var SKUs = APFDueProvider.GetAPFSkuList();

            if (SKUs != null && SKUs.Count == 2)
            {
                // if sku does not exist in the cart, add it
                // sku 1 is SP
                //string apfSKU = level == "SP" ? SKUs[1] : SKUs[0];
                string apfSKU = string.Empty;
                if (level == "SP")
                {
                    apfSKU = HLConfigManager.Configurations.APFConfiguration.SupervisorSku;
                }
                else
                {
                    apfSKU = HLConfigManager.Configurations.APFConfiguration.DistributorSku;
                }

                sku = new ShoppingCartItem_V01(0, apfSKU, 1, DateTime.Now);
            }
            return(sku);
        }
Esempio n. 12
0
 public bool InsertShoppingCartItem(string distributorID, ShoppingCartItem_V01 item, int shoppingCartID)
 {
     return(Providers.ShoppingCartProvider.InsertShoppingCartItem(distributorID, item, shoppingCartID));
 }
        public static bool checkVolumeLimits(MyHLShoppingCart cart, ref decimal previousVolumePoints, ShoppingCartRuleResult Result, PurchasingLimits_V01 currentLimits, string Locale, string Country, ShoppingCartItem_V01 currentItem)
        {
            decimal DistributorRemainingVolumePoints = 0;
            decimal NewVolumePoints = 0;

            if (currentLimits.PurchaseLimitType == PurchaseLimitType.None || currentLimits.LimitsRestrictionType != LimitsRestrictionType.PurchasingLimits)
            {
                return(true);
            }
            if (null == currentLimits)
            {
                return(false);
            }

            DistributorRemainingVolumePoints = currentLimits.RemainingVolume;

            var current = CatalogProvider.GetCatalogItem(currentItem.SKU, Country);

            if (current != null)
            {
                NewVolumePoints = current.VolumePoints * currentItem.Quantity;
            }

            if (NewVolumePoints > 0)
            {
                if (currentLimits.maxVolumeLimit == -1)
                {
                    return(true);
                }
                decimal cartVolume = cart.VolumeInCart + previousVolumePoints;
                previousVolumePoints += NewVolumePoints;

                if (DistributorRemainingVolumePoints - (cartVolume + NewVolumePoints) < 0)
                {
                    Result.Result = RulesResult.Failure;
                    var orderMonth = new OrderMonth(Country);
                    var msg        = HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform) ?? string.Empty, "VolumePointExceedsOnOrderMonth") as string;
                    msg = string.Format(msg, orderMonth.CurrentOrderMonth.ToString("MM-yyyy"), DistributorRemainingVolumePoints);
                    Result.AddMessage(msg);
                    cart.RuleResults.Add(Result);
                    return(false);
                }
            }
            return(true);
        }