Hello. I want to get the product stock count in the _ProductBox.cshtml so the category list will show if the product is out of stock. Does anyone have the code that will tell me in that view?
I am using nop 3.6.
Thanks.
model.CustomProperties.Add("stockQuantity", product.StockQuantity);
@if (Model.CustomProperties.ContainsKey("stockQuantity"))
{
<div class="quantity">
<span>Quantity:</span>
<span>@Model.CustomProperties["stockQuantity"]</span>
</div>
}
@using Nop.Services.Catalog;
@{}I added:
var productQuantity = EngineContext.Current.Resolve<IProductService>().GetProductById(Model.Id).StockQuantity;
@if (productQuantity < 1)
{
<span class="out-of-stock">Out of Stock</span>
}
@if (productQuantity < 1)
{
<span class="out-of-stock">Out of Stock</span>
}
@using Nop.Core.Infrastructure;
@using Nop.Services.Catalog;
@{}Add:
var productQuantity = EngineContext.Current.Resolve<IProductService>().GetProductById(Model.Id).StockQuantity;
@if (productQuantity < 1)
{
<span class="out-of-stock">Out of Stock</span>
}
else
{
<span class="stock-quantity">Stock Quantity: @productQuantity</span>
}