// Newer ECF 11 - Oct-17 internal Price GetTheRightCustomerPrice(ShirtVariation currentContent) { IEnumerable <IPriceValue> priceValues; // need to check if anonymous or not ... so the EffectiveGroup does not bother // Anonymous... could use the DefaultPrice, but may miss the tiered price if set at Anonymous if (CustomerContext.Current.CurrentContact == null) { PriceFilter filter = new PriceFilter() { Quantity = 1M, Currencies = new Currency[] { _marketService.GetCurrentMarket().Currencies.FirstOrDefault() }, // only have one at the moment... CustomerPricing = new CustomerPricing[] { new CustomerPricing(CustomerPricing.PriceType.AllCustomers, null), }, ReturnCustomerPricing = false // }; // The rest needed, CatKey, Market, TimeStamp CatalogKey catalogKey = new CatalogKey(currentContent.Code); // 3 overloads priceValues = _priceService.GetPrices( currentMarket.Service.GetCurrentMarket().MarketId.Value, FrameworkContext.Current.CurrentDateTime, catalogKey, filter); } else { // Logged on // no custom PriceTypes... yet PriceFilter filter = new PriceFilter() { Quantity = 1M, Currencies = new Currency[] { _marketService.GetCurrentMarket().Currencies.FirstOrDefault() }, // only have one at the moment... CustomerPricing = new CustomerPricing[] { new CustomerPricing(CustomerPricing.PriceType.AllCustomers, null), new CustomerPricing(CustomerPricing.PriceType.PriceGroup, CustomerContext.Current.CurrentContact.EffectiveCustomerGroup), // or several... new CustomerPricing(CustomerPricing.PriceType.UserName, CustomerContext.Current.CurrentContact.FirstName) }, ReturnCustomerPricing = false // // ... if true; gets all that applies }; // The rest needed, CatKey, Market, TimeStamp CatalogKey catalogKey = new CatalogKey(currentContent.Code); // 3 overloads priceValues = _priceService.GetPrices( currentMarket.Service.GetCurrentMarket().MarketId.Value, FrameworkContext.Current.CurrentDateTime, catalogKey, filter); } if (priceValues.Count() > 0) { return(new Price(priceValues.ToList().OrderBy(x => x.UnitPrice.Amount).FirstOrDefault())); } else { return(new Price()); // should not actually, could use default price... it's a demo } }
// check what we have in stock private void CheckWarehouses(ShirtVariation currentContent) { generalWarehouseInfo.Add("Entry inventory Tracked: " + currentContent.TrackInventory.ToString()); // other code in CommerceDemo\...\AdminPageTemplate // how many FFCenters IEnumerable <IWarehouse> fullfillmentCenters = warehouseRepository.Service.List() .Where(w => (currentContent.ApplicationId == w.ApplicationId.ToString()) && w.IsActive && w.IsFulfillmentCenter); if (fullfillmentCenters.Count() > 1) { generalWarehouseInfo.Add("More than one fullfillment centers, need custom logic"); } // get all WHs for enumeration and output to the view IEnumerable <IWarehouse> allWarehouses = warehouseRepository.Service.List(); Decimal requestedQuantity = 0M; // ...there is also an InventoryLoader foreach (var warehouse in allWarehouses) { //specificWarehouseInfo.Add(warehouse.Code); InventoryRecord inventoryRecord = inventoryService.Service.Get(currentContent.Code, warehouse.Code); // Nice extension //var inventory = currentContent.GetStockPlacement(); if (inventoryRecord == null) // means that the SKU is not referenced from that WH { specificWarehouseInfo.Add(String.Format("WH: {0} - Available Qty: {1} ", warehouse.Code, 0)); } else { specificWarehouseInfo.Add(String.Format( "WH: {0} - Available Qty: {1} - Req Qty: {2} " , warehouse.Code , inventoryRecord.PurchaseAvailableQuantity , inventoryRecord.PurchaseRequestedQuantity)); // may need to look at Back & Pre - qty specificWarehouseInfo.Add(String.Format( "BackOrderAvailable Qty: {0} - BackOrder Req Qty: {1} " , inventoryRecord.BackorderAvailableQuantity , inventoryRecord.BackorderRequestedQuantity)); requestedQuantity += inventoryRecord.PurchaseRequestedQuantity; } } generalWarehouseInfo.Add(String.Format("Total req qty: {0}", requestedQuantity)); // it adds up across WHs }