/// <summary> /// Splits a single item into packages /// </summary> private IEnumerable <List <USPSVolumetrics> > SplitItemIntoPackages(GetShippingOptionRequest.PackageItem item, int packagesNeeded, decimal currentWeight) { int splitHeight = Convert.ToInt32((GetTotalHeightForCartItem(item)) / packagesNeeded); int splitLength = Convert.ToInt32((GetTotalLengthForCartItem(item)) / packagesNeeded); int splitWidth = Convert.ToInt32((GetTotalWidthForCartItem(item)) / packagesNeeded); int splitWeight = Convert.ToInt32(currentWeight / packagesNeeded); var splitItems = new List <USPSVolumetrics>(); for (int i = 0; i < packagesNeeded; i++) { splitItems.Add(new USPSVolumetrics { Height = splitHeight, Length = splitLength, Weight = splitWeight, Width = splitWidth }); yield return(splitItems); splitItems = new List <USPSVolumetrics>(); } }
private decimal GetTotalHeightForCartItem(GetShippingOptionRequest.PackageItem item) { decimal height = item.ShoppingCartItem.Product.Height; return((height <= 0 ? 1 : height) * item.ShoppingCartItem.Quantity); }
private decimal GetTotalLengthForCartItem(GetShippingOptionRequest.PackageItem item) { decimal length = item.ShoppingCartItem.Product.Length; return((length <= 0 ? 1 : length) * item.ShoppingCartItem.Quantity); }
private async Task <decimal> GetHomeDeliveryCostOfItem(GetShippingOptionRequest.PackageItem packageItem) { return(await GetCostAsync(packageItem.Product.Id, packageItem.ShoppingCartItem.AttributesXml, packageItem.ShoppingCartItem.Quantity)); }