Multiple Store Setup - Show Product Quantity From Specific Warehouse Only

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
We have a business with locations in several cities/states that ship within a certain mile radius of their respective  warehouse. Presently, I'm using the multiple store setup with sub-domains, and the products are set up to use multiple warehouses.

I'm able to get the product to only show in the state/city where it is available by limiting it to specific stores in the product's configuration, but the product page displays the total quantity available in ALL warehouses, not just the one that store ships from.

I want each store to only show/deliver what is available in it's own warehouse. Where is the best place to start to customize NopCommerce (4.10) to do this?

Thank you.
5 years ago
Hi there,
I think I can achieve some of what I'm trying to accomplish above by editing the below (part of ProductServices.cs)

It sums the total stock quantity rather than show the stock quantity in each warehouse. Can anyone advise me on if it is feasible to customize the code to select the stock quantity by the warehouse ID?




       public virtual int GetTotalStockQuantity(Product product, bool useReservedQuantity = true, int warehouseId = 0)
        {
            if (product == null)
                throw new ArgumentNullException(nameof(product));

            if (product.ManageInventoryMethod != ManageInventoryMethod.ManageStock)
            {
                //We can calculate total stock quantity when 'Manage inventory' property is set to 'Track inventory'
                return 0;
            }

            if (!product.UseMultipleWarehouses)
                return product.StockQuantity;

            var pwi = product.ProductWarehouseInventory;
            if (warehouseId > 0)
            {
                pwi = pwi.Where(x => x.WarehouseId == warehouseId).ToList();
            }
            var result = pwi.Sum(x => x.StockQuantity);
            if (useReservedQuantity)
            {
                result = result - pwi.Sum(x => x.ReservedQuantity);
            }

            return result;
        }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.