small medium large xlarge

Generic-user-small
27 Mar 2009, 12:15
Marc Gunton (8 posts)

Guys,

Does anyone know what code is required to change a value on the click of a button? I’m tryng to implement an items in stock feature. I’ve got everything in place with the items in stock number next to the price, I just need to decrement the number when the customer clicks the checkout button.

Any ideas???

Marc

Generic-user-small
06 May 2009, 17:32
James West (104 posts)

You can’t get an answer to such an open ended question. Where is the avaialble stock wquantity stored?

If you have a stock model then you need a decrement_stock_Level method in your model. Call this whenever you feel that you need to update the stock levels and your view should just reflect the adjusted value.

You are not going to adjust available quantities until checkout has been successfully completed though (I hope) and you need to ensure that at the point of completing checkout that the chosen quantities are available.

Of course you will need to consider whether or not you need some kind of table lock between checking and updating because in that split second someone else may have completed checkout for the same items.

Think long and hard before implementing a solution and the right way should become obvious

You must be logged in to comment