Check product stock by variant

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
eduardo.ponzoni
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Mon Oct 01, 2012 4:42 pm

Check product stock by variant

Post by eduardo.ponzoni » Tue Oct 16, 2012 5:09 pm

Hello there!

My client's website has a requirement to explicitly show to the user if any of the product variants is in low stock or either out of stock.
How could I do to check the inventory, not just based on product id, but also its variants?

Thank you very much!

ableExpert
Ensign (ENS)
Ensign (ENS)
Posts: 15
Joined: Mon Oct 22, 2012 4:25 pm

Re: Check product stock by variant

Post by ableExpert » Mon Oct 22, 2012 5:31 pm

you can check any product variant like this

Code: Select all

        Product product=ProductDataSource.Load(1);
        ProductVariantCollection vars = ProductVariantDataSource.LoadForProduct(product.ProductId);
        foreach (ProductVariant var in vars)
        {
            if (var.VariantName == "ABC")
            {
               InventoryManagerData data= InventoryManager.CheckStock(product, var);
               if (data.InStock <= 0)
               {
                   ---------------------
               }
            }
        }      

Post Reply