Quote Originally Posted by jadebox View Post
Thanks for working on this module. It is a useful addition to Zen Cart. I'm considering using it to replace a stand-alone utility that I wrote years ago.

There is, however, the potential of a synchronization issue. For example, if an order for one or more of the products comes in while the admin is editing the quantities in the form then the quantity set when the form is submitted will not be correct.

A simple fix is to have the user enter a positive or negative number which is added to the existing product inventory in the SQL statement. I find this useful because it matches the workflow for handing off-site sales and incoming inventory where it is more natural to enter the amount of products sold or received.

A more robust fix would allow the user to enter either an absolute amount or a relative amount. For absolute quantities, you could include the current quantity for each product in hidden inputs in the form and when processing the updates add the difference to the quantity in the database.

When entering absolute quantities, there is the issue that there may be pending orders for some of the products. I don't think there's a right way to handle that situation (other than possibly displaying a warning message) because the software can't know if the products in the pending orders have been pulled from inventory or not.
thank you for the useful review.

i agree that the situation you are describing is tricky. perhaps, instead of changing the user inputs on the screen, i could change the logic. one could run into a couple of tricky situations, ie:

product a -> system inventory = 10; actual inventory 8.

prior to doing the update with this plugin, an order comes in for 2, so the system inventory is now 8. when the plugin does the update, it could calculate 10 - 8; and subtract 2 from the system inventory. the tricky part could be if a customer orders all 10 or 9, and now the plugin would calculate 0 or -1, and need to turn the item off... or alternatively, if the admin was increasing the inventory from 10 to 15, and during that period an order came in for 10, which resulted in the items status now going to off. should the plugin turn the item back on?

little bit of food for thought.

again, thanks for the input.