Open bleroy opened 10 years ago
My two cents on this:
What we are planning to do (re: automatic update of inventory on order) is to use a workflow. We would be adding Activities for this kind of interaction if they are missing (e.g., I don't think there is an UpdateInventoryActivity
).
The reasoning is that some of the applications we are looking at don't need/want automatic updates of the inventory.
That's an interesting idea. If it were just so that people can turn it on and off, I'd recommend to just put it into a separate feature. However, I see how having the possibility to tie custom behavior to inventory changes could be very compelling. What I'd be weary about is if the feature depended on the existence and behavior of a workflow that can be modified by the user. As far as I can tell, there's a basic behavior here that isn't going to need to be customized: if product is sold, decrement its inventory. That behavior, I think, should not depend on workflows, and should be a feature that can be turned on and off. Now we should absolutely have workflow activities for inventory changes built on top of that. For example, a scenario could be: if inventory falls below 10 on any product, shoot me an email, or if this particular product is below 50, start its ordering process for 100 more, or whatever.
Oh, and it goes both ways, being able to not just trigger activities on inventory changes, but also to build activities that update inventory.
I still don't agree that inventory should always automatically decrease as the product is sold. FIrst of all, there's a matter of defining when the product is actually sold. Is it on payment? What if the store takes bank tranfers, rather than credit card? The product then is sold when the payment is processed and received. Or maybe you want to tie the decrement of the inventory to the moment you process the order and actually put the product into the hands of a delivery service. The the inventory qould change in response to an updated of order status. Also, say we decrement the inventory because the checkout completed fine. Then the customer cancels the order. The invenotry should increase again, so we have to provide something there anyway. Maybe again, I want to decrease the inventory temporarily before the product is even sold to prevent people from buying what you are trying to buy, and then eventually increase it back if you don't go through the checkout in a given time. I am sure I am missing some cases.
My point is, automatic handling of the inventory is really complex. I see specific features being able to handle specific cases, however I I don't know what kind of "coverage" of the scenarios that would grant. I'd rather have all the blocks in place to build workflows to handle each case.
Again, we get into the topic of invenotry vs available inventory like we started in #92.
This is why there needs to be a default behavior that can be disabled by a setting or a feature, and workflow activities to enable the implementation of custom behavior. In the case of my business, the behavior I wanted, and that could be the default, is that the inventory is decremented when the order is created. Cancelling an order should put the products back in the inventory. The cases where the system fails and requires manual intervention are rare, and also unavoidable. We should not deal with that by introducing more complexity. Manual intervention in rare cases is really not an issue, it's a necessity.
I see it now. The feature would handle the simple case. The lego blocks for the workflows would allow handling more complex scenarios.
I still have a doubt regarding this:
Cancelling an order should put the products back in the inventory.
Doesn't that make the store vulnerable to similar attacks as those you described in https://github.com/bleroy/Nwazet.Commerce/issues/92#issuecomment-287101443 ? That is, if the customer is allowed to cancel an order.
No, because in order to exploit that, you'd have to create lots of actual orders, leaving your credit card number, then cancel them.
Originally reported by: André Rieussec (Bitbucket: Ventajou, GitHub: Ventajou)
Hi,
I've been working on integrating Nwazet.Commerce on my site, and noticed today that when placing an order the product inventory was not getting updated. Am I missing something or is that not possible right now? Any plans to make it possible?
Thanks!