source/Application/Model/Order.php
public function validateStock($oBasket)
    {
        foreach ($oBasket->getContents() as $key => $oContent) {
            try {
                $oProd = $oContent->getArticle(true, null, true);
            } catch (\OxidEsales\Eshop\Core\Exception\NoArticleException $oEx) {
                $oBasket->removeItem($key);
                throw $oEx;
            } catch (\OxidEsales\Eshop\Core\Exception\ArticleInputException $oEx) {
                $oBasket->removeItem($key);
                throw $oEx;
            }

            // check if its still available
            $dArtStockAmount = $oBasket->getArtStockInBasket($oProd->getId(), $key);
            $iOnStock = $oProd->checkForStock($oContent->getAmount(), $dArtStockAmount);
            if ($iOnStock !== true) {
                /** @var \OxidEsales\Eshop\Core\Exception\OutOfStockException $oEx */
                $oEx = oxNew(\OxidEsales\Eshop\Core\Exception\OutOfStockException::class);
                $oEx->setMessage('ERROR_MESSAGE_OUTOFSTOCK_OUTOFSTOCK');
                $oEx->setArticleNr($oProd->oxarticles__oxartnum->value);
                $oEx->setProductId($oProd->getId());
                $oEx->setBasketIndex($key);

                if (!is_numeric($iOnStock)) {
                    $iOnStock = 0;
                }
                $oEx->setRemainingAmount($iOnStock);
                throw $oEx;
            }
        }
    }
public function validateStock($oBasket)
    {
        foreach ($oBasket->getContents() as $key => $oContent) {
            try {
                $oProd = $oContent->getArticle(true, null, true);
            } catch (\OxidEsales\Eshop\Core\Exception\NoArticleException $oEx) {
                $oBasket->removeItem($key);
                throw $oEx;
            } catch (\OxidEsales\Eshop\Core\Exception\ArticleInputException $oEx) {
                $oBasket->removeItem($key);
                throw $oEx;
            }

            // check if its still available
            $dArtStockAmount = $oBasket->getArtStockInBasket($oProd->getId(), $key);
            $iOnStock = $oProd->checkForStock($oContent->getAmount(), $dArtStockAmount);
            if ($iOnStock !== true) {
                /** @var \OxidEsales\Eshop\Core\Exception\OutOfStockException $oEx */
                $oEx = oxNew(\OxidEsales\Eshop\Core\Exception\OutOfStockException::class);
                $oEx->setMessage('ERROR_MESSAGE_OUTOFSTOCK_OUTOFSTOCK');
                $oEx->setArticleNr($oProd->oxarticles__oxartnum->value);
                $oEx->setProductId($oProd->getId());
                $oEx->setBasketIndex($key);

                if (!is_numeric($iOnStock)) {
                    $iOnStock = 0;
                }
                $oEx->setRemainingAmount($iOnStock);
                throw $oEx;
            }
        }
    }
public function validateStock ( $ oBasket ) { foreach ( $ oBasket -> getContents ( ) as $ key => $ oContent ) { try { $ oProd = $ oContent -> getArticle ( true , null , true ) ; } catch ( \ OxidEsales \ Eshop \ Core \ Exception \ NoArticleException $ oEx ) { $ oBasket -> removeItem ( $ key ) ; throw $ oEx ; } catch ( \ OxidEsales \ Eshop \ Core \ Exception \ ArticleInputException $ oEx ) { $ oBasket -> removeItem ( $ key ) ; throw $ oEx ; } // check if its still available $ dArtStockAmount = $ oBasket -> getArtStockInBasket ( $ oProd -> getId ( ) , $ key ) ; $ iOnStock = $ oProd -> checkForStock ( $ oContent -> getAmount ( ) , $ dArtStockAmount ) ; if ( $ iOnStock !== true ) { /** @var \OxidEsales\Eshop\Core\Exception\OutOfStockException $oEx */ $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ OutOfStockException :: class ) ; $ oEx -> setMessage ( 'ERROR_MESSAGE_OUTOFSTOCK_OUTOFSTOCK' ) ; $ oEx -> setArticleNr ( $ oProd -> oxarticles__oxartnum -> value ) ; $ oEx -> setProductId ( $ oProd -> getId ( ) ) ; $ oEx -> setBasketIndex ( $ key ) ; if ( ! is_numeric ( $ iOnStock ) ) { $ iOnStock = 0 ; } $ oEx -> setRemainingAmount ( $ iOnStock ) ; throw $ oEx ; } } }
Function which checks if article stock is valid.
If not displays error and returns false.

@param object $oBasket basket object

@throws \OxidEsales\Eshop\Core\Exception\NoArticleException
@throws \OxidEsales\Eshop\Core\Exception\ArticleInputException
@throws \OxidEsales\Eshop\Core\Exception\OutOfStockException
Function which checks if article stock is valid . If not displays error and returns false .