View Full Version : Inventory Question

01-26-2012, 05:20 PM
My question is more related to process than actually coding.

When dealing with an inventory, what is the best approach to managing the inventory so that you don't under sell nor over sell.

When is the best time to decrease the quantity of the inventory, when the user puts the product in their shopping cart or after a successful purchase?

If the inventory is decreased after the product is put in the shopping cart, then if the inventory is =0, then no one else can put the product in their shopping cart, and the product would show as sold out. But if the user never purchases their shopping cart, then the inventory would be incorrect, because it would show one less product that was actually sold.

Now if you only decrease the inventory after a successful purchase, then you could have a user put the product in their shopping cart, and then when going to pay for the product, then find that the inventory is now 0.

So is it best practice to have two inventorys, pre-purchase and post-purchase?

The product I'm developing could have multiple people attempt to buy a limited quantity of product in a short time, so I don't want to undersell nor oversell.

Hopefully I articuated this question clearly!

01-26-2012, 05:26 PM
Without a doubt, use post-inventory update. The reason is because thousands of people like myself add items to a shopping cart to see how much shipping will cost. Other start to buy and decide not to.

Also your item still exists until after checkout, you didn't actually sell it until you have received payment for it.

If you have 3 quantity and someone has 3 quantity in their shopping. Then another person adds 1 - 3 to theirs, and the one with 3 quantity checks out first. Make a message to the second person that says like "Sorry but we just ran out of that item, check back soon for more".

01-27-2012, 04:10 AM
add 'hold-timeout' to your process...

so, when i add a product into my cart it adds a hold timeout value so other browsers would see no product available if i'd added the last one to my cart...

then if i don't checkout in a certain timeout time it then becomes available again to visitors..

it should prob depend on your type of shoppers too, if they regularly just add to cart but don't checkout then myfayt's solution is probably best but if your visitors usually go to checkout when adding to cart a timeout solution would be best

hope this makes sense...

01-27-2012, 04:16 AM
I agree with jm. You should at least consider the possibility of a "hold" on items. If I go to purchase something that says there are 4 in stock, then get to the last step of the check out process and suddenly there are only 2, I'm going to be pretty frustrated.

I don't have any research to back this up, but it would seem to me that the best time to attach the hold is as soon as the checkout process begins for a certain item. That way you still have items in stock as people are browsing, but the user is notified BEFORE they begin a checkout process whether or not their items are still available.

Obviously you should then have some timeout to "replenish" your stock if someone never completes the checkout process.