You can do both those things. InventoryOnHand will be returned as part of the product XML ready for use in your XSLT templates or as part of the custom properties if you're working with .NET.
Using it from XML is very straightforward, just grab the attribute value and test on it being great than 0. XSLT makes it easy to filter out products, which don't have any inventory on hand.
From .NET you can go product["InventoryOnHand"] and it will output the current stock level.
If you're using Razor, you can get it with the following:
@product.DynamicProperty().InventoryOnHand
Assuming you've already set the product with SiteContext.Current.CatalogContext.CurrentProduct and all the rest, and there are no variants for the product.
I guess you would have to add a custom variant property (type number) to the products, and add your own checkout + ToCancelled pipeline to keep the variant inventory numbers up to date.
Handling InventoryOnHand
How can InventoryOnHand be utlised? For instance, how can I:
Hi Robin,
You can do both those things. InventoryOnHand will be returned as part of the product XML ready for use in your XSLT templates or as part of the custom properties if you're working with .NET.
Using it from XML is very straightforward, just grab the attribute value and test on it being great than 0. XSLT makes it easy to filter out products, which don't have any inventory on hand.
From .NET you can go product["InventoryOnHand"] and it will output the current stock level.
Hope this helps.
If you're using Razor, you can get it with the following:
@product.DynamicProperty().InventoryOnHand
Assuming you've already set the product with SiteContext.Current.CatalogContext.CurrentProduct and all the rest, and there are no variants for the product.
Hey Tracey,
What if the product has variants?
I need it this way. Can you please help me?
I guess you would have to add a custom variant property (type number) to the products, and add your own checkout + ToCancelled pipeline to keep the variant inventory numbers up to date.
InventoryOnHand is also supported on the variant level and will be handled automatically for you.
Docs at Simple Inventory Management with uCommerce.
is working on a reply...