/// <summary> /// Creates a list up to 12 DistributorShoppingCartItems with the parameters given /// </summary> /// <param name="locale">Locale</param> /// <param name="skus">Array of skus to be taken</param> /// <param name="lines">Number of lines to be added</param> /// <param name="qty">Quantity for each line</param> /// <returns>List of DistributorShoppingCartItem</returns> public static List <DistributorShoppingCartItem> GetDistributorShoppingCartItemList(string locale, List <string> skus, int lines, int qty) { var distributorShoppingCartItemList = new List <DistributorShoppingCartItem>(); var linesToAdd = (skus.Count < lines) ? skus.Count : lines; for (int i = 0; i < linesToAdd; i++) { distributorShoppingCartItemList.Add(ShoppingCartItemHelper.GetCatalogItems(1, qty, skus[i], locale)); } return(distributorShoppingCartItemList); }
/// <summary> /// Gets the 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> /// <returns> /// Shopping cart with the parameters. /// </returns> internal static MyHLShoppingCart GetBasicShoppingCart(string distributorId, string locale, string freightCode, string wareHouseCode, bool calculate, OrderTotals_V01 totals) { 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 = new List <DistributorShoppingCartItem> { ShoppingCartItemHelper.GetShoppingCartItem(1, 1, "1231"), ShoppingCartItemHelper.GetShoppingCartItem(2, 1, "0138"), ShoppingCartItemHelper.GetShoppingCartItem(3, 1, "0139") }, CartItems = new ShoppingCartItemList { ShoppingCartItemHelper.GetCartItem(1, 1, "1231"), ShoppingCartItemHelper.GetCartItem(2, 1, "0138"), ShoppingCartItemHelper.GetCartItem(3, 1, "0139") }, DistributorID = string.IsNullOrEmpty(distributorId) ? "webtest1" : distributorId, FreightCode = freightCode, 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) }; // 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 }; } return(shoppingCart); }