private DeliveryOption getDeliveryOptionFromID(int deliveryOptionID, DeliveryOptionType type, List <DeliveryOption> deliveryOptions, OrderCategoryType orderCategoryType) { if (deliveryOptions != null && deliveryOptions.Count > 0) { if (deliveryOptionID >= 0) { var options = deliveryOptions.Where(x => x.Option == type && x.OrderCategory == orderCategoryType); if (options.Count() > 0) { return(options.First()); } } else { return(deliveryOptions.Find(x => x.Id == deliveryOptionID && x.Option == type)); } } return(null); }
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)); }
/// <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); }