When an order is created by a store admin manually, the autocomplete product lookup tool shows all products, not just those that are in stock.

In my case, this is fine for the main store admin as they know what is in stock and what isn't, but for the others that help out, this could lead to orders being created with items being unavailable.

Is it wrong of me to suggest that this is a bug? I think that there at least needs to be some visual means of showing what is in stock and what isn't, perhaps not even showing what's out of stock.

Comments

rszrama’s picture

Title: Manual order creation allows for out of stock products to be added » Notify or prevent addition of out of stock products to orders by administrators
Project: Commerce Core » Commerce Stock
Version: 7.x-1.2 » 7.x-2.x-dev
Component: Order » User interface
Category: bug » feature

Remember that the core of Drupal Commerce doesn't involve stock management at all - that comes through the Commerce Stock module. I don't really think it's a bug as administrators should be free to build orders however they want. It's akin to them being able to build an order with products and discount them all to $0.

That said, it might be a fine feature request for the Stock module, though it may not be feasible until we've revamped the line item manager widget in core.

guy_schneerson’s picture

rszrama , agree it would make a nice feature but should inform and not enforce.

Maybe something to look into in the future. I am focusing on getting the functionality to be as API based as possible this will hopefully make it easier to add this kind of functionality in the future.

rszrama’s picture

Status: Active » Postponed

Great, and I'm of the same mind as you - an administrator should be able to get around this sort of thing. I'd make that the default behavior and only pursue actual prevention if there was a real need for some sort of permission based override. But right now you have to be a trusted user anyways to go around editing orders manually.

kiwimind’s picture

Thank you both for your feedback. Some very valid points in there.

I'll keep my eyes open for this request in the future.

In the meantime, can you think of a straightforward way of differentiating which products are in stock and which aren't?

Thanks again.

mattnorman2003’s picture

Has anyone ever come up with a solution or workaround for this?

I have same requirement that orders can be created manually by users who can take orders over the phone but will not have access to the product admin area of the site and will not know stock levels. Just a simple warning that the item is out of stock or a way of displaying the stock level when they add it to the order would be sufficient.

mattnorman2003’s picture

Ok - I did actually find a workaround for this - since I wanted to make some other changes to the line items widget used on this screen I ended up creating a new widget for use here and added the validation into the widget. This is probably not the best way to do it but it's a working solution for the time being.

guy_schneerson’s picture

Status: Postponed » Active

I was planning on using hook_field_widget_form_alter() on the existing commerce_line_item_manager widget type for this.
If you got the time would be great to see what you have done, no need for a patch you can upload a file with code or just post PHP.

I am changing from the postponed to active as I think this is needed

mattnorman2003’s picture

I can do that when I have something I'm happy with - at the moment it's not quite working how I want because the validation happens when just changing something on the order such as the order status. It should really only validate the stock levels if the actual line item quantity has been changed.

For example we have 50 of product X in stock.
Order 1 created manually for 30 of product X, order saved, stock decreased to 20.
Order 2 created for 20 of product X, stock decreased to 0.
Order 1 edited to change order status from pending to processing (in my system this is used to trigger an email to the customer to say their order is being processed and will be dispatched in x days). Now the validation fires and the order can't be saved because we have 0 of product X in stock.