Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Mar 2010
    Posts
    13
    Plugin Contributions
    0

    Default 2 customers order same item (1 in stock) and checkout successfully

    The problem occurs when 2 people place an order for the same item when the stock level is low. When 2 orders are placed very close together they are both allowed to check out the same item.

    If there is 1 left in stock and they both check out too close together both checkouts complete correctly, the result being you have sold the same single item twice.
    All the stock control options set to not subtract stock and not allow checkout.

    I haven't witnessed this myself, I have been told by a fellow zencart user that they have seen the same 'bug' on several occasions on their very busy site and have not found a solution here.
    I have searched and not found anything in the forums.
    He's using an unmodified install of zencart (version 1.3.8 I believe).

    I've used zencart for a number of years on a quieter site, but this week I'm launching a new site which will sell out 1 product, 100 in stock in less than an hour, and I'm really concerned we will hit the same problem and sell more than we have stock for.

    Can anyone tell me if this is an issue that has been raised before? Or been fixed? or anything?

    Thanks

  2. #2
    Join Date
    Jan 2004
    Posts
    66,391
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: 2 customers order same item (1 in stock) and checkout successfully

    That's just a fact of life, especially when you're commonly selling one-of-a-kind items.

    Write the 2nd customer a very nice letter and invite them to select from some alternate similar products, or refund them entirely.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Mar 2010
    Posts
    13
    Plugin Contributions
    0

    Default Re: 2 customers order same item (1 in stock) and checkout successfully

    Please tell me this isn't the only solution?

    We will have 100 of a particular product, if we sell 101 of them, mr 101 will be really upset.
    Its not that we are selling one of a kind products, its just that we have a limited stock.

    Can it not be protected against by mutex or similar?

    Surely someone else has seen this?
    If not can I post it as a bug?

  4. #4
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,207
    Plugin Contributions
    11

    Default Re: 2 customers order same item (1 in stock) and checkout successfully

    It's not a bug and there's no way of controlling this situation without tying cart sessions to stock.

    Zen Cart allows you to put items in your cart without stopping someone else from doing so. Otherwise, I could go to your cart, put 100 of your widgets in my cart, and head out for the day never intending to buy anything.

    Under your change, until my session died, no one would be able to order any widgets.

    The way it works now, you could have 10 widgets left, and 15 people online with one in their cart. If all decide to complete through checkout, you'll be needing to contact some folks.

    Personally, I see it as a good problem. At least a LOT better than someone tying up product for hours without buying.

    I think we're talking the new DOP hack. (Denial of Product)

  5. #5
    Join Date
    Jan 2004
    Posts
    66,391
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: 2 customers order same item (1 in stock) and checkout successfully

    Quote Originally Posted by ColourfulDesigns View Post
    Please tell me this isn't the only solution?

    We will have 100 of a particular product, if we sell 101 of them, mr 101 will be really upset.
    Its not that we are selling one of a kind products, its just that we have a limited stock.

    Can it not be protected against by mutex or similar?

    Surely someone else has seen this?
    If not can I post it as a bug?
    I do understand your predicament, and you're not the first person to encounter such a situation. And I'm not trying to be contrary or antagonistic or belligerent just to be a pain. Please excuse the tone if it comes off that way. There are technical reasons for taking this position.

    Please ... tell me just exactly how you propose the ideal solution to work?
    I'm guessing you're going to say that as soon as someone puts the product in their cart you want to remove it from stock immediately, right? And then when the next person comes along they can't put it in their cart because it's no longer there since it's out of stock. But then the first person decides they like the price better somewhere else, or maybe they get distracted by a phone call and just abandon their cart. Meanwhile the second customer who was READY to buy and had their credit card in-hand, just waiting to give YOU money ... they can't get one, and YOU lose the sale. Aw shucks.
    Making a refund is a LOT better than losing a sale. And, if the refund or offered-refund is done properly, it could actually convert into another sale and/or potentially several more sales or upsells. That customer will not be as "really upset" as *you* will be for having lost both sales since you made it impossible for the motivated buyer to actually buy something.

    So, next you're going to tell me that some sort of automated process could then magically remove the items from abandoned carts and put them back in stock. Granted, that will happen LONG AFTER the 2nd customer has been refused opportunity to purchase what he had intended to buy and has since left your site and gone elsewhere to get it. So, that's not a total solution either.

    Not to mention the fact that your competitors could easily roam around your store putting everything in a shopping cart and abandoning them, thus totally preventing all your customers from making purchases.


    As dbltoe has stated, the software is working as-designed. It's not a bug.
    Zen Cart already checks stock levels at every step of the checkout process right up until the last possible moment when payment is collected. If two customers happen to be clicking the "pay" button at the same instant, it is possible to get two completed legitimate sales.


    Or is there some magical solution you're seeing that I'm not? I'm happy to listen to workable solutions.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Jul 2005
    Location
    UK and Ireland
    Posts
    258
    Plugin Contributions
    1

    Default Re: 2 customers order same item (1 in stock) and checkout successfully

    That'squite a reply Dr Byte - too much coffee perhaps ;)

    I once thought about this: if product A's stock level = 1 and someone has this product in their basket then on the product page it annouces that "a client has this product in their shopping basket; buy now before stock runs out"

    It may help to quicken sales..
    Last edited by JSWeb; 26 Jul 2010 at 09:25 AM.

  7. #7
    Join Date
    Jan 2004
    Posts
    66,391
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: 2 customers order same item (1 in stock) and checkout successfully

    Quote Originally Posted by JSWeb View Post
    That'squite a reply Dr Byte - too much coffee perhaps ;)
    Perhaps. Or maybe not enough.
    Quote Originally Posted by JSWeb View Post
    I once thought about this: if product A's stock level = 1 and someone has this product in their basket then on the product page it annouces that "a client has this product in their shopping basket; buy now before stock runs out"

    It may help to quicken sales..
    Yes, it may help quicken sales, but doesn't actually solve the stated problem. Just exacerbates it.
    And adds more database query hits in the process (potentially lots of queries depending on how many shoppers (active or not) have products in their cart.)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Mar 2010
    Posts
    13
    Plugin Contributions
    0

    Default Re: 2 customers order same item (1 in stock) and checkout successfully

    DrBryte,

    I fully understand the issue of holding carts, its pointless and achieves nothing helpful, I agree.
    But there are other carts that don't see this issue, so either they are protecting against it or the timing is much tighter their reducing the possibility of it occurring.

    I haven't done alot of sychronisation/mutexing etc in php, it is not my native language, I have however done it in other languages. I'm a hardware level software programmer for real time systems, were timing like this is absolutely cruecial.
    So excuse me if the exact method is incorrect for php, but theory should still apply.

    As I see it 2 possible solutions that come to mine:
    1. Using in built db synchronisation.
    When a person clicks the final part of checkout (not payment but the checkout of zencart) and we go to sql to do the check and subtract stock, we synchronise the access to that product, so only 1 thread (ie customer session) can check, subtract, check the stock level. When we have done that we can release the sync, the next thread trying to access the same product will then get access when it does its check it will see the stock level is already zero, release the sync, return to the customer and say out of stock.

    2. Creating a section of access checking for products.
    When a person clicks the final part of checkout (not payment but the checkout of zencart) can we check and subtract the stock
    (using sql to subtract the value, not reading it from the db minusing 1 and writing it back!),
    then recheck it, if its zero (and not a minus number) we can return to the customer and say checkout successful, if we get a minus number, we know we have had a hit and will have to put the stock for that customer back, and tell them it is now out of stock.
    Now due to timing it is entirely possible for both sessions to return the minus stock, so I believe we would have to associate a session id to the db access and use the one which chronologically comes first to allocate the stock.


    There are millions of other ways php and sql are used where double subtraction of a value would be critical and there must be a way around that.

    I understand that zencart is operating as designed, I just feel there is room for improvement in this area.

    Thoughts?

  9. #9
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: 2 customers order same item (1 in stock) and checkout successfully

    In your first post you are stating

    Quote Originally Posted by ColourfulDesigns View Post
    ........All the stock control options set to not subtract stock and not allow checkout.....
    If you don't subtract your sold items from stock on-hand then how pray tell can the system implement "don't allow checkout when there is no stock left" ??

    Or was it a typo from your end ?

  10. #10
    Join Date
    Mar 2010
    Posts
    13
    Plugin Contributions
    0

    Default Re: 2 customers order same item (1 in stock) and checkout successfully

    Sorry that was a typo.
    Its set to check stock, subtract stock, and now allow checkout.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. mixed no shipping and per item shipping on same order
    By MDIWade in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 25 Jul 2011, 05:08 AM
  2. Offer discount for customers who re-purchase the same item?
    By yellow1912 in forum General Questions
    Replies: 4
    Last Post: 21 Feb 2009, 04:05 PM
  3. Replies: 3
    Last Post: 23 May 2008, 04:51 PM
  4. need help with "in stock" - How do I add an item not in stock but is made-to-order?
    By DravenLS in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 1 Dec 2007, 09:18 PM
  5. Replies: 2
    Last Post: 3 Jul 2006, 02:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR