Skip to content
View in the app

A better way to browse. Learn more.

thirty bees forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Bug resulting in negative stock despite "deny orders" setting

Featured Replies

I have a product with attributes. I've noticed that sometimes I get negative stock, even though orders should be denied if there isn't enough stock. The setting in the Preferences>Products page is "Deny order" and the Product>Quantities setting is "Default> Deny orders as set in the Products Preferences page".

I've now been able to reproduce the issue.

  1. Customer A places item with combination Y in shopping cart.
  2. Customer B places item with combination Y in shopping cart.
  3. Total of items with combination Y placed in shopping cart by Customers A and B exceeds amount in stock.
  4. Customer A checks out.
  5. Customer B checks out.
  6. Stock is now negative and both customers successfully placed their orders.
  • Author

A p.s.: The order from customer B was paid by credit card (Stripe module) and went to the status "paid" and then automatically to "on backorder (paid)".

There is an option to allow ordering out of stock products in the back office. Is it possible that you allowed it?

  • 2 months later...

hi, sorry for bump old post, do you found the solution? I'm having this problem too. 2 order in same time, the second customer get error message "order not valid", but the order still go through

I've test several times with fresh install 1.0.4, the problem still there, the second customer get "On backorder (not paid)" on the order status. as you can see I've disable backorder. can this be a bug? I can confirm PS 1.6.1.18 have this problem too.

0_1525482253280_Screenshot from 2018-05-05 08-02-08.png

  • 1 year later...
  • Author

This surfaced again. The stock of all combinations was 0 and when I visit the product page I am unable to place the product in the cart. So I don't understand how the customer could have bought the product. Does anyone have an idea of how this could have happened?

I don't know where the check of this feature is. If the check is on the addToCart function, then it won't work, when the customer had it already in the cart. It goes like this:

  1. customer 1 puts product in the cart
  2. customer 2 puts product in the cart
  3. customer 1 places the order

I am not sure if it's like that. This is just my assmption...

 

Edit: Sorry that is actually your first post 😅 Is there no check on the checkout?

I am not using the inbuilt setting, so I don't know, how it works. But I am using this on checkout:

    // Check if stock of a product is still available (it could be ordered in the meantime)
    public function initContent() {

        $products_in_cart = $this->context->cart->getProducts();
        $deleted_products = array();

        foreach ($products_in_cart as $product_in_cart) {
            if ($product_in_cart['quantity_available']==0) {
                $this->context->cart->deleteProduct($product_in_cart['id_product'], $product_in_cart['id_product_attribute']);
                $deleted_products[] = $product_in_cart['name'];
            }
        }

        $this->context->smarty->assign(
            array(
                'opc_deleted_products' => $deleted_products,
            )
        );

        parent::initContent();
    }

Maybe it can't help you too...

  • Author

Thanks, @wakabayashi! The odd thing is that I can't even put it in the shopping cart. I think your assumption is right that it must have been in the shopping cart already when the stock finally reached 0.

@datakick, can I use wakabayashi's code in Chex and where exactly would I put it in there? 

The problem is that order is created "after" payment is already processed. And it's just not possible to NOT create it at this time. The money are already on the way, so we need to track it against some order / customer.

If the stock meanwhile decreased to zero between the product was added to cart and order was paid, the result will be order on backorder. 

It's not possible to fix this problem completely, not without fundamental change to ordering process.There will always be some timespan when this can happen, we can only limit it to the minimum. For example by checking the availability just before the customer is redirected to payment gateway. But with 3DSecure / SCA / SMS confirmations the payment can take a long time, so this issue can still occur. 

Regarding your question -- no, you can't use this with chex. But I'll add this 'last second' availability check to limit this to the minimum. Will be in the next version

@datakick your are right, this doesn't prevent, if you are at payment. But in our case 9 out of 10 times the issue was like that: 

  1. customer 1 places product x to cart
  2. customer 1 is making a pizza 🍕
  3. customer 2 places product x to cart
  4. customer 2 orders product x
  5. product x is no more available
  6. two hours later customer 1 has eaten his pizza and orders product x

This case is now prevented. For now we have the issue only left if some customer are ordering inside like 5 minutes product x.

My code from above is only a few days old, since we had the "pizza" case a lot in these corona times.

@wakabayashi

I think this case of cart being revalidated before order exists already. There is a message that asks user to remove the out of stock product or the order will not proceed.

@Chandra oh ok interesting. As I said this is just my own "solution". 

In my case it's wanted, that customer can order 5, if we have only 4 left. But he shouldn't been able to order 1 if 0 is left. I know very strange 🤣

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.