Open jedateach opened 12 years ago
There are several flaws with how the Shopping-Cart and Order-Items are updated:
beforeAdd
, afterAdd
, beforeRemove
, afterRemove
etc. but these don't provide good tools to intercept unwanted changes (other than throwing an Exception, which doesn't allow to do something like clamping quantity to a max-amount or similar)add
and setQuantity
(where 2 extension hooks exist per operation). Ideally, item modification would only need one place for validation.We need to think about:
The easiest way to implement rollbacks are probably DB transactions. Since we already use DB transactions in OrderProcessor::placeOrder
, we could use them to roll-back an invalid cart. That would mean that SilverShop will only support Databases with transaction support.
It is easy to get items in the cart which shouldn't be in there.
When should items be validated
What should happen to invalid items
Examples