LineItem InStockQuantity always 0 - 10.1.1


We've upgraded to 10.1.1 and discovered that the InStockQuantity property always returns 0.

Other properties regarding stock status seems also to return 0.

Anyone know why? 

We've built a temporary way around it for now.

Dec 20, 2016 10:08


Are you using the concrete classes (OrderForm, LineItem, etc), or the new abstraction (IOrderForm, ILineItem etc)?

Do you use the workflows?


Dec 20, 2016 10:41

We extract the LineItems through the CartHelper so we're using the concrete classes. We use the information to structure the content on the page where we display the current content depending which type of items contained therein.

The way we alleviated the problem for now was building an extension which extracts the code from the lineitem and finds the variation to get to know current in stock value.

Dec 21, 2016 8:51

If you are using the workflows, then that value should be set in OrderGroupActivityBase.PopulateInventoryInfo. Can you check if the values are correctly set there?

Dec 21, 2016 11:30

We're running the CartValidate-workflow. Could it be that it is till running the old workflow instead of VNext?

Jan 02, 2017 16:43

That's strange. That function should be run if you are using the "old" workflow. As I said you can download the Workflow project, include it in your solution, build it and debug to see if it is actually called.

Jan 02, 2017 16:46

Where do I find the workflow project for download?

I noticed that the WarehouseCode is empty in our case which results in empty result when running [ecf_Inventory_GetInventory]. Could that be the culprit?

Jan 02, 2017 17:05

You should be able to use this:

We will put the new one for Commerce 10 soon. 

Jan 02, 2017 20:25

The problem was with WarehouseCode. We were not using it explicitly and in version 9 and previous it seems to have handled empty warehousecodes by setting them to "Default". But in version 10 that seems to be removed. This caused problems with the inventory-numbers but affected also other things dependant on the WarehouseCode.

Jan 03, 2017 14:01

The LineItem.WarehouseCode property is now obsoleted - the order system will only work with Shipment.WarehouseCode. However other parts of system were also updated, so it should work just fine - the check for inventories should take the Shipment.WarehouseCode and check it against LineItems in that Shipment. Do you have custom code which does otherwise?

Jan 03, 2017 14:11

We had to add entries to the cart with this method in CartHelper:

public virtual LineItem AddEntry(Entry entry, Decimal quantity, bool fixedQuantity, string warehouseCode, params CartHelper[] helpersToRemove)

Earlier we used this:

public virtual LineItem AddEntry(Entry entry, Decimal quantity, bool fixedQuantity, params CartHelper[] helpersToRemove)

This solved our problem and quantity is evaluated in a correct way.

Jan 10, 2017 8:36

@Tobias, you have upgraded to 10, but still use legacy Cart and LineItem objects?

Edited, Jan 26, 2017 16:09
<p>It's perfectly fine to use legacy Cart (or even CartHelper) and LineItem in Commerce 10. I can imagine many customers upgrade so they can use the new features/bug fixes, especially in the new promotion system. But yes, it's highly recommended to move to the new abstraction APIs ASAP.</p>
Feb 01, 2017 10:56
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.