
Originally Posted by
eyeb
Hello,
Zen Cart 1.5.4. We sell many 1 only products and when sold there is no backorder. When two people add the same item to their cart the first one to checkout gets the item - BUT the second person can also checkout and pay but there is no more stock to give them. In the normal use of Zen Cart this doesn't happen - it removes the item from the second person's cart before they can checkout (and takes it off the site). However when using Stock by Attribute it leaves the item in the second person's cart and they can still checkout. We want two or more people to add to their carts since not everyone checks out - but once someone buys the item we don't want others to checkout. Is there a fix to this - a change to the code we can do? Or a setting that we've missed? Thanks - cool addon overall.

Originally Posted by
mc12345678
What is the source of the version you have installed and when was it last installed/updated?
Took a look at the code during the checkout process, specifically includes/modules/pages/checkout_confirmation/header_php.php and how it relates to SBA 1.5.4, on line 108 (ZC 1.5.2, 1.5.3, and 1.5.4) there is a check that looks like it needs to be modified slightly. This file will get incorporated into the SBA code, but can be easily changed here.
Change:
Code:
if ($stock_check[$i] = zen_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {
to: by adding , $order->products[$i]['attributes'] into the zen_check_stock statement:
Code:
if ($stock_check[$i] = zen_check_stock($order->products[$i]['id'], $order->products[$i]['qty'], $order->products[$i]['attributes'])) {
Without this additional attribute information, then the stock check is made against the base product instead of the SBA tracked quantity. Thus if the product had two attributes each being tracked, if say they both had a quantity of 1, then during the above situation of two people each adding the same attributed product to the cart and "racing" to purchase, well the quantity check would have indicated that there was still one product left, but wouldn't account for having 0 products matching that attribute... With the above, that issue should be resolved.
Bookmarks