Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

These support forums are now closed for new topics and comments.
Please head on over to for support.

  • Javier Barrera 34 posts 85 karma points
    Nov 04, 2011 @ 23:38
    Javier Barrera

    Get Inventory on Hand

    I'm curious how I get the inventory on hand for a product.

    We have many varient products setup with the inventory also specified in uCommerce. Basically I can check if "AllowOrdering" is set to true on the product - but if I specify a quantity of 1000 when I only have 10, I'm still allowed to enter than many into the cart.

    I've looked through, and it appears that the only class that will do anything with inventory is the UCommerce.Pipelines.Common.InventoryTask. However, it doesn't appear to allow me to do anything but increment or decrement the number.

  • Javier Barrera 34 posts 85 karma points
    Nov 05, 2011 @ 03:29
    Javier Barrera

    I ended up getting the solution.

               ProductDefinition definition = product.ProductDefinition;
    foreach (ProductDefinitionField field in definition.ProductDefinitionFields)
    if (field.Name == "InventoryOnHand")
    ProductProperty property = ProductProperty.FirstOrDefault(x => x.ProductId == product.Id && x.ProductDefinitionFieldId == field.Id);

    if (property != null)
    int availableInventory;

    if (int.TryParse(property.Value, out availableInventory))
    return availableInventory;

Please Sign in or register to post replies

Write your reply to: