Returns array of discounts that can be globally (transparently) applied

@param \OxidEsales\Eshop\Application\Model\Article $oArticle article object
@param \OxidEsales\Eshop\Application\Model\User    $oUser    oxuser object (optional)

@return array
330211
public function getArticleDiscounts($oArticle, $oUser = null)
    {
        $aList = [];
        $aDiscList = $this->_getList($oUser)->getArray();
        foreach ($aDiscList as $oDiscount) {
            if ($oDiscount->isForArticle($oArticle)) {
                $aList[$oDiscount->getId()] = $oDiscount;
            }
        }

        return $aList;
    }
640032
public function isForArticle($oArticle)
    {
        // item discounts may only be applied for basket
        if ($this->oxdiscount__oxaddsumtype->value == 'itm') {
            return false;
        }

        if ($this->oxdiscount__oxamount->value || $this->oxdiscount__oxprice->value) {
            return false;
        }

        if ($this->oxdiscount__oxpriceto->value && ($this->oxdiscount__oxpriceto->value < $oArticle->getBasePrice())) {
            return false;
        }

        if ($this->isGlobalDiscount()) {
            return true;
        }

        $sArticleId = $oArticle->getProductId();

        if (!isset($this->_aHasArticleDiscounts[$sArticleId])) {
            $blResult = $this->_isArticleAssigned($oArticle) || $this->_isCategoriesAssigned($oArticle->getCategoryIds());

            $this->_aHasArticleDiscounts[$sArticleId] = $blResult;
        }

        return $this->_aHasArticleDiscounts[$sArticleId];
    }
340704
public function getRecommListsUrl(\OxidEsales\Eshop\Application\Model\Article $oArticle)
    {
        $oLang = Registry::getLang();
        $iLang = $oLang->getBaseLanguage();

        return $this->_prepareUrl(
            "cl=rss&amp;fnc=recommlists&amp;anid=" . $oArticle->getId(),
            $oLang->translateString("LISTMANIA", $iLang) . "/" . $oArticle->oxarticles__oxtitle->value
        );
    }
918968
public function getUserPayments()
    {
        if ($this->_oUserPayments == null) {
            $this->_oUserPayments = false;
            if ($oUser = $this->getUser()) {
                $sTplLang = \OxidEsales\Eshop\Core\Registry::getLang()->getObjectTplLanguage();
                $sPaymentId = $this->getPaymentId();
                $this->_oUserPayments = $oUser->getUserPayments();
                // generate selected
                foreach ($this->_oUserPayments as $oUserPayment) {
                    $oPayment = oxNew(\OxidEsales\Eshop\Application\Model\Payment::class);
                    $oPayment->setLanguage($sTplLang);
                    $oPayment->load($oUserPayment->oxuserpayments__oxpaymentsid->value);
                    $oUserPayment->oxpayments__oxdesc = clone $oPayment->oxpayments__oxdesc;
                    if ($oUserPayment->oxuserpayments__oxid->value == $sPaymentId) {
                        $oUserPayment->selected = 1;
                        break;
                    }
                }
            }
        }

        return $this->_oUserPayments;
    }
233872
protected function _checkForArticleCategories($oArticle)
    {
        // check if article is in some assigned category
        $aCatIds = $oArticle->getCategoryIds();
        if (!$aCatIds || !count($aCatIds)) {
            // no categories are set for article, so no discounts from categories..
            return false;
        }

        $sCatIds = "(" . implode(",", \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quoteArray($aCatIds)) . ")";

        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        // getOne appends limit 1, so this one should be fast enough
        $sQ = "select oxobjectid from oxobject2discount where oxdiscountid = " . $oDb->quote($this->oxdiscount__oxid->value) . " and oxobjectid in $sCatIds and oxtype = 'oxcategories'";

        return $oDb->getOne($sQ);
    }
188047
public function applyDiscountsForVariant($oPrice)
    {
        // apply discounts
        if (!$this->skipDiscounts()) {
            $oDiscountList = \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Application\Model\DiscountList::class);
            $aDiscounts = $oDiscountList->getArticleDiscounts($this, $this->getArticleUser());

            reset($aDiscounts);
            foreach ($aDiscounts as $oDiscount) {
                $oPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
            }
            $oPrice->calculateDiscount();
        }
    }
284720
protected function GetReviewsForArticle($oActiveArticle)
    {
        $oModuleConfiguration = $this->GetModuleConfiguration();
        if ($oActiveArticle->IsVariant()) {
            $oActiveArticle = $oActiveArticle->GetFieldVariantParent();
        }
        $oActiveCategory = TdbShop::GetActiveCategory();

        $this->data['oActiveCategory'] = $oActiveCategory;
        $this->data['oActiveArticle'] = $oActiveArticle;
        if ($oModuleConfiguration->fieldAllowRateReview) {
            $oReviewList = TdbShopArticleReviewList::GetReviewsForArticleSortedByRate($oActiveArticle->id);
        } else {
            $oReviewList = TdbShopArticleReviewList::GetListForShopArticleId($oActiveArticle->id);
        }
        $oReviewList->AddFilterString("`shop_article_review`.`publish`='1'");

        return $oReviewList;
    }
741151
protected function GetReviewsForUser()
    {
        $oUserReviews = null;
        $oUser = TdbDataExtranetUser::GetInstance();
        if ($oUser->IsLoggedIn()) {
            $oUserReviews = $oUser->GetFieldShopArticleReviewList();
        }

        return $oUserReviews;
    }
440812
protected function checkUserGroup(TdbDataExtranetUser $oUser)
    {
        $bIsValidGroup = false;
        $aUserGroups = $this->getPaymentMethodDataAccess()->getPermittedUserGroupIds($this->id);
        if (!is_array($aUserGroups) || count($aUserGroups) < 1) {
            $bIsValidGroup = true;
        } elseif ($oUser->IsLoggedIn()) {
            $bIsValidGroup = $oUser->InUserGroups($aUserGroups);
        }

        return $bIsValidGroup;
    }
1105217
protected function _isAvailableInOtherOrder($oUser)
    {
        $oSeries = $this->getSerie();
        if (!$oSeries->oxvoucherseries__oxallowuseanother->value) {
            $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
            $sSelect = 'select count(*) from ' . $this->getViewName() . ' where oxuserid = ' . $oDb->quote($oUser->oxuser__oxid->value) . ' and ';
            $sSelect .= 'oxvoucherserieid = ' . $oDb->quote($this->oxvouchers__oxvoucherserieid->value) . ' and ';
            $sSelect .= '((oxorderid is not NULL and oxorderid != "") or (oxdateused is not NULL and oxdateused != 0)) ';

            if ($oDb->getOne($sSelect)) {
                $oEx = oxNew(\OxidEsales\Eshop\Core\Exception\VoucherException::class);
                $oEx->setMessage('ERROR_MESSAGE_VOUCHER_NOTALLOWEDSAMESERIES');
                $oEx->setVoucherNr($this->oxvouchers__oxvouchernr->value);
                throw $oEx;
            }
        }

        return true;
    }
45746
public function getArticleVat(\OxidEsales\Eshop\Application\Model\Article $oArticle)
    {
        startProfile("_assignPriceInternal");
        // article has its own VAT ?

        if (($dArticleVat = $oArticle->getCustomVAT()) !== null) {
            stopProfile("_assignPriceInternal");

            return $dArticleVat;
        }
        if (($dArticleVat = $this->_getVatForArticleCategory($oArticle)) !== false) {
            stopProfile("_assignPriceInternal");

            return $dArticleVat;
        }

        stopProfile("_assignPriceInternal");

        return \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('dDefaultVAT');
    }
574611
protected function _setUser($oUser)
    {

        $this->oxorder__oxuserid = new \OxidEsales\Eshop\Core\Field($oUser->getId());

        // bill address
        $this->oxorder__oxbillcompany = clone $oUser->oxuser__oxcompany;
        $this->oxorder__oxbillemail = clone $oUser->oxuser__oxusername;
        $this->oxorder__oxbillfname = clone $oUser->oxuser__oxfname;
        $this->oxorder__oxbilllname = clone $oUser->oxuser__oxlname;
        $this->oxorder__oxbillstreet = clone $oUser->oxuser__oxstreet;
        $this->oxorder__oxbillstreetnr = clone $oUser->oxuser__oxstreetnr;
        $this->oxorder__oxbilladdinfo = clone $oUser->oxuser__oxaddinfo;
        $this->oxorder__oxbillustid = clone $oUser->oxuser__oxustid;
        $this->oxorder__oxbillcity = clone $oUser->oxuser__oxcity;
        $this->oxorder__oxbillcountryid = clone $oUser->oxuser__oxcountryid;
        $this->oxorder__oxbillstateid = clone $oUser->oxuser__oxstateid;
        $this->oxorder__oxbillzip = clone $oUser->oxuser__oxzip;
        $this->oxorder__oxbillfon = clone $oUser->oxuser__oxfon;
        $this->oxorder__oxbillfax = clone $oUser->oxuser__oxfax;
        $this->oxorder__oxbillsal = clone $oUser->oxuser__oxsal;


        // delivery address
        if (($oDelAdress = $this->getDelAddressInfo())) {
            // set delivery address
            $this->oxorder__oxdelcompany = clone $oDelAdress->oxaddress__oxcompany;
            $this->oxorder__oxdelfname = clone $oDelAdress->oxaddress__oxfname;
            $this->oxorder__oxdellname = clone $oDelAdress->oxaddress__oxlname;
            $this->oxorder__oxdelstreet = clone $oDelAdress->oxaddress__oxstreet;
            $this->oxorder__oxdelstreetnr = clone $oDelAdress->oxaddress__oxstreetnr;
            $this->oxorder__oxdeladdinfo = clone $oDelAdress->oxaddress__oxaddinfo;
            $this->oxorder__oxdelcity = clone $oDelAdress->oxaddress__oxcity;
            $this->oxorder__oxdelcountryid = clone $oDelAdress->oxaddress__oxcountryid;
            $this->oxorder__oxdelstateid = clone $oDelAdress->oxaddress__oxstateid;
            $this->oxorder__oxdelzip = clone $oDelAdress->oxaddress__oxzip;
            $this->oxorder__oxdelfon = clone $oDelAdress->oxaddress__oxfon;
            $this->oxorder__oxdelfax = clone $oDelAdress->oxaddress__oxfax;
            $this->oxorder__oxdelsal = clone $oDelAdress->oxaddress__oxsal;
        }
    }
298597
protected function _getVatForArticleCategory(\OxidEsales\Eshop\Application\Model\Article $oArticle)
    {
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sCatT = getViewName('oxcategories');

        if ($this->_blCatVatSet === null) {
            $sSelect = "SELECT oxid FROM $sCatT WHERE oxvat IS NOT NULL LIMIT 1";

            //no category specific vats in shop?
            //then for performance reasons we just return false
            $this->_blCatVatSet = (bool) $oDb->getOne($sSelect);
        }

        if (!$this->_blCatVatSet) {
            return false;
        }

        $sO2C = getViewName('oxobject2category');
        $sSql = "SELECT c.oxvat
                 FROM $sCatT AS c, $sO2C AS o2c
                 WHERE c.oxid=o2c.oxcatnid AND
                       o2c.oxobjectid = " . $oDb->quote($oArticle->getId()) . " AND
                       c.oxvat IS NOT NULL
                 ORDER BY o2c.oxtime ";

        $fVat = $oDb->getOne($sSql);
        if ($fVat !== false && $fVat !== null) {
            return $fVat;
        }

        return false;
    }
1137805
public function getArticleMainUri($oArticle, $iLang)
    {
        startProfile(__FUNCTION__);

        $oMainCat = $this->_getMainCategory($oArticle);
        $sMainCatId = $oMainCat ? $oMainCat->getId() : '';

        //load default article url from DB
        if (!($sSeoUri = $this->_loadFromDb('oxarticle', $oArticle->getId(), $iLang, null, $sMainCatId, true))) {
            // save for main category
            if ($oMainCat) {
                $sSeoUri = $this->_createArticleCategoryUri($oArticle, $oMainCat, $iLang);
            } else {
                // get default article url
                $oArticle = $this->_getProductForLang($oArticle, $iLang);
                $sSeoUri = $this->_processSeoUrl($this->_prepareArticleTitle($oArticle), $oArticle->getId(), $iLang);

                // save default article url
                $this->_saveToDb(
                    'oxarticle',
                    $oArticle->getId(),
                    $oArticle->getBaseStdLink($iLang),
                    $sSeoUri,
                    $iLang,
                    null,
                    0,
                    ''
                );
            }
        }

        stopProfile(__FUNCTION__);

        return $sSeoUri;
    }
718981
public function isForBasketItem($oArticle)
    {
        if ($this->oxdiscount__oxamount->value == 0 && $this->oxdiscount__oxprice->value == 0) {
            return false;
        }

        // skipping bundle discounts
        if ($this->oxdiscount__oxaddsumtype->value == 'itm') {
            return false;
        }

        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        // check if this article is assigned
        $sQ = "select 1 from oxobject2discount where oxdiscountid = " . $oDb->quote($this->oxdiscount__oxid->value) . " and oxtype = 'oxarticles' ";
        $sQ .= $this->_getProductCheckQuery($oArticle);
        if (!($blOk = ( bool ) $oDb->getOne($sQ))) {
            // checking article category
            $blOk = $this->_checkForArticleCategories($oArticle);
        }

        return $blOk;
    }
1304879
protected function _getForeignCountryUserVat(\OxidEsales\Eshop\Application\Model\User $oUser, \OxidEsales\Eshop\Application\Model\Country $oCountry)
    {
        if ($oCountry->isInEU()) {
            if ($oUser->oxuser__oxustid->value) {
                return 0;
            }

            return false;
        }

        return 0;
    }
961859
public function SaveVouchers(TShopBasketVoucherList $oBasketVoucherList)
    {
        if (!is_null($this->id) && !is_null($oBasketVoucherList) && $oBasketVoucherList->Length() > 0) {
            $oBasketVoucherList->GoToStart();
            while ($oVoucherItemUsed = $oBasketVoucherList->Next()) {
                $oVoucherItemUsed->CommitVoucherUseForCurrentUser($this->id);
            }
        }
    }