How to get the product in stock availability on the product list?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 năm cách đây
How to get the product in stock availability on the product list?

@if (!Model.ProductPrice.DisableBuyButton)
                {
                    var addToCartText = T("ShoppingCart.AddToCart").Text;
                    if (Model.ProductPrice.IsRental)
                    {
                        addToCartText = T("ShoppingCart.Rent").Text;
                    }
                    if (Model.ProductPrice.AvailableForPreOrder)
                    {
                        addToCartText = T("ShoppingCart.PreOrder").Text;
                    }
                    <input type="button" value="В корзину" class="button-2 product-box-add-to-cart-button" onclick="AjaxCart.addproducttocart_catalog('@addtocartlink    ');return false;" /> <br/>

                    @Model.StockAvailability;   ???
                }

use @Model.StockAvailability ?

but i receive error

'Nop.Web.Models.Catalog.ProductOverviewModel' does not contain a definition for 'StockAvailability' and no extension method 'StockAvailability' accepting a first argument of type 'Nop.Web.Models.Catalog.ProductOverviewModel' could be found (are you missing a using directive or an assembly reference?)

my ver 3.50

Thenks!
7 năm cách đây
gnikitsin wrote:
How to get the product in stock availability on the product list?

@if (!Model.ProductPrice.DisableBuyButton)
                {
                    var addToCartText = T("ShoppingCart.AddToCart").Text;
                    if (Model.ProductPrice.IsRental)
                    {
                        addToCartText = T("ShoppingCart.Rent").Text;
                    }
                    if (Model.ProductPrice.AvailableForPreOrder)
                    {
                        addToCartText = T("ShoppingCart.PreOrder").Text;
                    }
                    <input type="button" value="В корзину" class="button-2 product-box-add-to-cart-button" onclick="AjaxCart.addproducttocart_catalog('@addtocartlink    ');return false;" /> <br/>

                    @Model.StockAvailability;   ???
                }

use @Model.StockAvailability ?

but i receive error

'Nop.Web.Models.Catalog.ProductOverviewModel' does not contain a definition for 'StockAvailability' and no extension method 'StockAvailability' accepting a first argument of type 'Nop.Web.Models.Catalog.ProductOverviewModel' could be found (are you missing a using directive or an assembly reference?)

my ver 3.50

Thenks!


Go through the previous post==>https://www.nopcommerce.com/boards/t/42329/how-to-display-out-of-stock-in-the-product-box.aspx#169459

Hope it will help you. You can ask more question if needed.
7 năm cách đây
Although reference version is not same to your version. But work is similar ===>https://www.nopcommerce.com/boards/t/42329/how-to-display-out-of-stock-in-the-product-box.aspx#169470
7 năm cách đây
sohel wrote:
Although reference version is not same to your version. But work is similar ===>https://www.nopcommerce.com/boards/t/42329/how-to-display-out-of-stock-in-the-product-box.aspx#169470


thenks sohel
7 năm cách đây
sohel wrote:
Although reference version is not same to your version. But work is similar ===>https://www.nopcommerce.com/boards/t/42329/how-to-display-out-of-stock-in-the-product-box.aspx#169470



@{
    var product = Nop.Core.Infrastructure.EngineContext.Current.Resolve<Nop.Services.Catalog.IProductService>().GetProductById(Model.Id);

    var stockMessage = string.Empty;

    if (product != null)
    {
        stockMessage = product.StockQuantity == 0 ? "Out of stock" : "Avaliable in Stock";
    }

}
<span>@stockMessage</span>

i receive error

A local variable named 'product' cannot be declared in this scope because it would give a different meaning to 'product', which is already used in a 'child' scope to denote something else
7 năm cách đây
gnikitsin wrote:
Although reference version is not same to your version. But work is similar ===>https://www.nopcommerce.com/boards/t/42329/how-to-display-out-of-stock-in-the-product-box.aspx#169470


@{
    var product = Nop.Core.Infrastructure.EngineContext.Current.Resolve<Nop.Services.Catalog.IProductService>().GetProductById(Model.Id);

    var stockMessage = string.Empty;

    if (product != null)
    {
        stockMessage = product.StockQuantity == 0 ? "Out of stock" : "Avaliable in Stock";
    }

}
<span>@stockMessage</span>

i receive error

A local variable named 'product' cannot be declared in this scope because it would give a different meaning to 'product', which is already used in a 'child' scope to denote something else


You have the already  variable name "product" sore use


@{
    var product1 = Nop.Core.Infrastructure.EngineContext.Current.Resolve<Nop.Services.Catalog.IProductService>().GetProductById(Model.Id);

    var stockMessage = string.Empty;

    if (product1 != null)
    {
        stockMessage = product1.StockQuantity == 0 ? "Out of stock" : "Avaliable in Stock";
    }

}
<span>@stockMessage</span>
7 năm cách đây
sohel wrote:
Although reference version is not same to your version. But work is similar ===>https://www.nopcommerce.com/boards/t/42329/how-to-display-out-of-stock-in-the-product-box.aspx#169470


@{
    var product = Nop.Core.Infrastructure.EngineContext.Current.Resolve<Nop.Services.Catalog.IProductService>().GetProductById(Model.Id);

    var stockMessage = string.Empty;

    if (product != null)
    {
        stockMessage = product.StockQuantity == 0 ? "Out of stock" : "Avaliable in Stock";
    }

}
<span>@stockMessage</span>

i receive error

A local variable named 'product' cannot be declared in this scope because it would give a different meaning to 'product', which is already used in a 'child' scope to denote something else

You have the already  variable name "product" sore use


@{
    var product1 = Nop.Core.Infrastructure.EngineContext.Current.Resolve<Nop.Services.Catalog.IProductService>().GetProductById(Model.Id);

    var stockMessage = string.Empty;

    if (product1 != null)
    {
        stockMessage = product1.StockQuantity == 0 ? "Out of stock" : "Avaliable in Stock";
    }

}
<span>@stockMessage</span>



thenks. work )
7 năm cách đây
Good afternoon sohel. How can I update the data automatically? Somehow through Ajax? After applying the filter, the data is not displayed, it is necessary to update the page. Because of what the filter gets knocked out.
7 năm cách đây
gnikitsin wrote:
Good afternoon sohel. How can I update the data automatically? Somehow through Ajax? After applying the filter, the data is not displayed, it is necessary to update the page. Because of what the filter gets knocked out.


Good afternoon,

"How can I update the data automatically? Somehow through Ajax?" ==>yes you can

"After applying the filter, the data is not displayed, it is necessary to update the page. Because of what the filter gets knocked out."==> you can update whole page. Or you can update only some portion by Ajax.
7 năm cách đây
sohel wrote:
Good afternoon sohel. How can I update the data automatically? Somehow through Ajax? After applying the filter, the data is not displayed, it is necessary to update the page. Because of what the filter gets knocked out.

Good afternoon,

"How can I update the data automatically? Somehow through Ajax?" ==>yes you can

"After applying the filter, the data is not displayed, it is necessary to update the page. Because of what the filter gets knocked out."==> you can update whole page. Or you can update only some portion by Ajax.


Only part, where the data on the warehouse
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.