private PackageList PreparePackages(Warehouse origin, Address destination, BasketItemCollection contents) { PackageList plist = PackageManager.GetPackageList(contents); if (plist == null || plist.Count == 0) { return(null); } ProviderUnits pUnits = GetProviderUnits(origin.Country); //GET UNITS USED BY STORE Store store = Token.Instance.Store; MeasurementUnit storeMeasurementUnit = store.MeasurementUnit; WeightUnit storeWeightUnit = store.WeightUnit; bool requireMC = storeMeasurementUnit != pUnits.MeasurementUnit; bool requireWC = storeWeightUnit != pUnits.WeightUnit; if (requireMC && requireWC) { plist.ConvertBoth(pUnits.WeightUnit, pUnits.MeasurementUnit); } else if (requireWC) { plist.ConvertWeight(pUnits.WeightUnit); } else if (requireMC) { plist.ConvertDimensions(pUnits.MeasurementUnit); } WeightUnit sourceUnit = (Token.Instance.Store.WeightUnit == WeightUnit.Grams || Token.Instance.Store.WeightUnit == WeightUnit.Kilograms) ? WeightUnit.Kilograms : WeightUnit.Pounds; LSDecimal maxWeight = LocaleHelper.ConvertWeight(sourceUnit, MaxPackageWeight, pUnits.WeightUnit); LSDecimal minWeight = LocaleHelper.ConvertWeight(sourceUnit, MinPackageWeight, pUnits.WeightUnit); if (EnablePackageBreakup && maxWeight > 0) { //compose packages (splits items larger than the maximum carrier weight) plist.Compose(maxWeight, minWeight); } else { plist.EnsureMinimumWeight(minWeight); } //convert weight and dimensions to whole numbers plist.ConvertDimsToWholeNumbers(); plist.RoundWeight(1); return(plist); }
private PackageList PreparePackages(Warehouse origin, BasketItemCollection contents) { PackageList plist = PackageManager.GetPackageList(contents); if (plist == null || plist.Count == 0) { return(null); } //GET UNITS USED BY STORE Store store = StoreDataSource.Load(Token.Instance.StoreId); MeasurementUnit storeMeasurementUnit = store.MeasurementUnit; WeightUnit storeWeightUnit = store.WeightUnit; bool requireMC = storeMeasurementUnit != MeasurementUnit.Inches; bool requireWC = storeWeightUnit != WeightUnit.Ounces; if (requireMC && requireWC) { plist.ConvertBoth(WeightUnit.Ounces, MeasurementUnit.Inches); } else if (requireWC) { plist.ConvertWeight(WeightUnit.Ounces); } else if (requireMC) { plist.ConvertDimensions(MeasurementUnit.Inches); } LSDecimal maxWeight = LocaleHelper.ConvertWeight(WeightUnit.Pounds, MaxPackageWeight, WeightUnit.Ounces); LSDecimal minWeight = LocaleHelper.ConvertWeight(WeightUnit.Pounds, MinPackageWeight, WeightUnit.Ounces); if (EnablePackageBreakup && maxWeight > 0) { //compose packages (splits items larger than the maximum carrier weight) plist.Compose(maxWeight, minWeight); } else { plist.EnsureMinimumWeight(minWeight); } //convert weight to whole number //plist.ConvertWeightToWholeNumber(); //plist.ConvertDimsToWholeNumbers(); return(plist); }
private PackageList PreparePackages(Warehouse origin, BasketItemCollection contents) { PackageList plist = PackageManager.GetPackageList(contents); if (plist == null || plist.Count == 0) { return(null); } ProviderUnits pUnits = GetProviderUnits(origin.Country); //GET UNITS USED BY STORE Store store = StoreDataSource.Load(Token.Instance.StoreId); MeasurementUnit storeMeasurementUnit = store.MeasurementUnit; WeightUnit storeWeightUnit = store.WeightUnit; bool requireMC = storeMeasurementUnit != pUnits.MeasurementUnit; bool requireWC = storeWeightUnit != pUnits.WeightUnit; if (requireMC && requireWC) { plist.ConvertBoth(pUnits.WeightUnit, pUnits.MeasurementUnit); } else if (requireWC) { plist.ConvertWeight(pUnits.WeightUnit); } else if (requireMC) { plist.ConvertDimensions(pUnits.MeasurementUnit); } LSDecimal maxWeight = LocaleHelper.ConvertWeight(WeightUnit.Kilograms, MaxPackageWeight, pUnits.WeightUnit); LSDecimal minWeight = LocaleHelper.ConvertWeight(WeightUnit.Kilograms, MinPackageWeight, pUnits.WeightUnit); if (EnablePackageBreakup && maxWeight > 0) { //compose packages (splits items larger than the maximum carrier weight) plist.Compose(maxWeight, minWeight); } else { plist.EnsureMinimumWeight(minWeight); } return(plist); }