source/Application/Model/Basket.php
public function canAddProductToBasket($sProductId)
    {
        $blCanAdd = null;

        // if basket category is not set..
        if ($this->_sBasketCategoryId === null) {
            $oCat = null;

            // request category
            if ($oView = \OxidEsales\Eshop\Core\Registry::getConfig()->getActiveView()) {
                if ($oCat = $oView->getActiveCategory()) {
                    if (!$this->_isProductInRootCategory($sProductId, $oCat->oxcategories__oxrootid->value)) {
                        $oCat = null;
                    } else {
                        $blCanAdd = true;
                    }
                }
            }

            // product main category
            if (!$oCat) {
                $oProduct = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
                if ($oProduct->load($sProductId)) {
                    $oCat = $oProduct->getCategory();
                }
            }

            // root category id
            if ($oCat) {
                $this->setBasketRootCatId($oCat->oxcategories__oxrootid->value);
            }
        }

        // avoiding double check..
        if ($blCanAdd === null) {
            $blCanAdd = $this->_sBasketCategoryId ? $this->_isProductInRootCategory($sProductId, $this->getBasketRootCatId()) : true;
        }

        return $blCanAdd;
    }
public function canAddProductToBasket($sProductId)
    {
        $blCanAdd = null;

        // if basket category is not set..
        if ($this->_sBasketCategoryId === null) {
            $oCat = null;

            // request category
            if ($oView = \OxidEsales\Eshop\Core\Registry::getConfig()->getActiveView()) {
                if ($oCat = $oView->getActiveCategory()) {
                    if (!$this->_isProductInRootCategory($sProductId, $oCat->oxcategories__oxrootid->value)) {
                        $oCat = null;
                    } else {
                        $blCanAdd = true;
                    }
                }
            }

            // product main category
            if (!$oCat) {
                $oProduct = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
                if ($oProduct->load($sProductId)) {
                    $oCat = $oProduct->getCategory();
                }
            }

            // root category id
            if ($oCat) {
                $this->setBasketRootCatId($oCat->oxcategories__oxrootid->value);
            }
        }

        // avoiding double check..
        if ($blCanAdd === null) {
            $blCanAdd = $this->_sBasketCategoryId ? $this->_isProductInRootCategory($sProductId, $this->getBasketRootCatId()) : true;
        }

        return $blCanAdd;
    }
public function canAddProductToBasket ( $ sProductId ) { $ blCanAdd = null ; // if basket category is not set.. if ( $ this -> _sBasketCategoryId === null ) { $ oCat = null ; // request category if ( $ oView = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getActiveView ( ) ) { if ( $ oCat = $ oView -> getActiveCategory ( ) ) { if ( ! $ this -> _isProductInRootCategory ( $ sProductId , $ oCat -> oxcategories__oxrootid -> value ) ) { $ oCat = null ; } else { $ blCanAdd = true ; } } } // product main category if ( ! $ oCat ) { $ oProduct = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; if ( $ oProduct -> load ( $ sProductId ) ) { $ oCat = $ oProduct -> getCategory ( ) ; } } // root category id if ( $ oCat ) { $ this -> setBasketRootCatId ( $ oCat -> oxcategories__oxrootid -> value ) ; } } // avoiding double check.. if ( $ blCanAdd === null ) { $ blCanAdd = $ this -> _sBasketCategoryId ? $ this -> _isProductInRootCategory ( $ sProductId , $ this -> getBasketRootCatId ( ) ) : true ; } return $ blCanAdd ; }
Checks if product can be added to basket

@param string $sProductId product id

@return bool
Checks if product can be added to basket