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!
Check product stock by variant
-
- Ensign (ENS)
- Posts: 8
- Joined: Mon Oct 01, 2012 4:42 pm
-
- Ensign (ENS)
- Posts: 15
- Joined: Mon Oct 22, 2012 4:25 pm
Re: Check product stock by variant
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)
{
---------------------
}
}
}