homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / WebmasterWorld / Ecommerce
Forum Library, Charter, Moderators: buckworks

Ecommerce Forum

shopping cart question
when to subtract the item from stock quantities?

5+ Year Member

Msg#: 3634131 posted 1:54 pm on Apr 24, 2008 (gmt 0)

Is it best practice to subtract the quantity of an item when it has been added to a user's cart or upon completion of the checkout process?



10+ Year Member

Msg#: 3634131 posted 2:19 pm on Apr 24, 2008 (gmt 0)

I can see an argument for each but due to abandoned carts I would say it is better (if not fairer) on checkout completion so it's the first person to checkout that gets the worm rather than first to add to cart.


5+ Year Member

Msg#: 3634131 posted 2:28 pm on Apr 24, 2008 (gmt 0)

That is what I was thinking as well. It will also make it easier for us to track current inventory.


10+ Year Member

Msg#: 3634131 posted 3:35 pm on Apr 24, 2008 (gmt 0)

I don't think there's really a perfect solution... but I think it's unlikely that you'd end up with a customer missing out because another customer beat them to it. If there is a risk of this, then perhaps you should hold more stock?!

I do a second check at the point that the customer clicks 'Checkout' to make sure the quantities in the cart are still not above the inventory level. I'm not sure you can do anything better than this.



WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 3634131 posted 4:31 pm on Apr 24, 2008 (gmt 0)

Here is what we do. It drove me nuts getting it all worked out, but this is what we currently have.

We have three tables in our DB, stock_inventory, pending_inventory, and purchase_inventory (for example.)

When customers are adding items to cart, we don't do anything at all. When they make a purchase, the items are added to pending. When the item is shipped, it subtracts the pending from stock, and adds the pending to purchases. This gets really complex when you're dealing with item options (an item that has color, finish, and size options is not really "1 item.")

The pending status is important. We've had a few fraud attempts or people call up and cancel an item in an order. We remove the item from their cart and it just removes it from pending, no items have been moved out of stock at that point.

Visible from the product display is stock minus pending.

This is also not perfect, as it doesn't "reserve" items put in a cart, only when they are checked out. We considered many approaches to this, the most likely being a "timeout" - the items go into pending for X hours. The problem there is we have even had customers organize a cart on Sunday and not actually complete the purchase until Thursday.

Also there is the potential for "cart fraud" by competitors, similar to click fraud with adWords. All a competitor has to do is figure out your stock decrements when items go into your cart, then they can go in and "buy up" your stock without buying anything. Legitimate customers see no stock and move on.

The bottom line, I guess, is it's not sold until it's sold, so if one customer beats another to it, that's just the way the early bird works. We're sticking with decrementing at point of sale.

Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / Ecommerce
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved