src/ShopBundle/objects/db/TShopVoucher.class.php
public function AllowVoucherForArticle(TShopBasketArticle $oArticle)
    {
        $bMayBeUsed = true;

        $oVoucherDef = &$this->GetFieldShopVoucherSeries();

        if ($oArticle->fieldExcludeFromVouchers && empty($oVoucherDef->fieldShopVoucherSeriesSponsorId)) {
            $bMayBeUsed = false;
        }

        // check article restrictions
        if ($bMayBeUsed) {
            $aArticleRestrictons = $oVoucherDef->GetMLTIdList('shop_article_mlt');
            if (count($aArticleRestrictons) > 0 && !in_array($oArticle->id, $aArticleRestrictons)) {
                $bMayBeUsed = false;
            }
        }

        // check manufacturer restrictions
        if ($bMayBeUsed) {
            $aManufacturerRestrictons = $oVoucherDef->GetMLTIdList('shop_manufacturer_mlt');
            if (count($aManufacturerRestrictons) > 0 && !in_array($oArticle->fieldShopManufacturerId, $aManufacturerRestrictons)) {
                $bMayBeUsed = false;
            }
        }

        // check category restrictions
        if ($bMayBeUsed) {
            $aCategoryRestrictons = $oVoucherDef->GetMLTIdList('shop_category_mlt');
            if (count($aCategoryRestrictons) > 0) {
                if (!$oArticle->IsInCategory($aCategoryRestrictons)) {
                    $bMayBeUsed = false;
                }
            }
        }

        // check product group restrictions
        if ($bMayBeUsed) {
            $aArticleGroupRestrictons = $oVoucherDef->GetMLTIdList('shop_article_group_mlt');
            if (count($aArticleGroupRestrictons) > 0) {
                $aGroups = $oArticle->GetMLTIdList('shop_article_group_mlt');
                $aMatches = array_intersect($aGroups, $aArticleGroupRestrictons);
                if (0 == count($aMatches)) {
                    $bMayBeUsed = false;
                }
            }
        }

        return $bMayBeUsed;
    }
public function AllowVoucherForArticle(TShopBasketArticle $oArticle)
    {
        $bMayBeUsed = true;

        $oVoucherDef = &$this->GetFieldShopVoucherSeries();

        if ($oArticle->fieldExcludeFromVouchers && empty($oVoucherDef->fieldShopVoucherSeriesSponsorId)) {
            $bMayBeUsed = false;
        }

        // check article restrictions
        if ($bMayBeUsed) {
            $aArticleRestrictons = $oVoucherDef->GetMLTIdList('shop_article_mlt');
            if (count($aArticleRestrictons) > 0 && !in_array($oArticle->id, $aArticleRestrictons)) {
                $bMayBeUsed = false;
            }
        }

        // check manufacturer restrictions
        if ($bMayBeUsed) {
            $aManufacturerRestrictons = $oVoucherDef->GetMLTIdList('shop_manufacturer_mlt');
            if (count($aManufacturerRestrictons) > 0 && !in_array($oArticle->fieldShopManufacturerId, $aManufacturerRestrictons)) {
                $bMayBeUsed = false;
            }
        }

        // check category restrictions
        if ($bMayBeUsed) {
            $aCategoryRestrictons = $oVoucherDef->GetMLTIdList('shop_category_mlt');
            if (count($aCategoryRestrictons) > 0) {
                if (!$oArticle->IsInCategory($aCategoryRestrictons)) {
                    $bMayBeUsed = false;
                }
            }
        }

        // check product group restrictions
        if ($bMayBeUsed) {
            $aArticleGroupRestrictons = $oVoucherDef->GetMLTIdList('shop_article_group_mlt');
            if (count($aArticleGroupRestrictons) > 0) {
                $aGroups = $oArticle->GetMLTIdList('shop_article_group_mlt');
                $aMatches = array_intersect($aGroups, $aArticleGroupRestrictons);
                if (0 == count($aMatches)) {
                    $bMayBeUsed = false;
                }
            }
        }

        return $bMayBeUsed;
    }
public function AllowVoucherForArticle ( TShopBasketArticle $ oArticle ) { $ bMayBeUsed = true ; $ oVoucherDef = & $ this -> GetFieldShopVoucherSeries ( ) ; if ( $ oArticle -> fieldExcludeFromVouchers && empty ( $ oVoucherDef -> fieldShopVoucherSeriesSponsorId ) ) { $ bMayBeUsed = false ; } // check article restrictions if ( $ bMayBeUsed ) { $ aArticleRestrictons = $ oVoucherDef -> GetMLTIdList ( 'shop_article_mlt' ) ; if ( count ( $ aArticleRestrictons ) > 0 && ! in_array ( $ oArticle -> id , $ aArticleRestrictons ) ) { $ bMayBeUsed = false ; } } // check manufacturer restrictions if ( $ bMayBeUsed ) { $ aManufacturerRestrictons = $ oVoucherDef -> GetMLTIdList ( 'shop_manufacturer_mlt' ) ; if ( count ( $ aManufacturerRestrictons ) > 0 && ! in_array ( $ oArticle -> fieldShopManufacturerId , $ aManufacturerRestrictons ) ) { $ bMayBeUsed = false ; } } // check category restrictions if ( $ bMayBeUsed ) { $ aCategoryRestrictons = $ oVoucherDef -> GetMLTIdList ( 'shop_category_mlt' ) ; if ( count ( $ aCategoryRestrictons ) > 0 ) { if ( ! $ oArticle -> IsInCategory ( $ aCategoryRestrictons ) ) { $ bMayBeUsed = false ; } } } // check product group restrictions if ( $ bMayBeUsed ) { $ aArticleGroupRestrictons = $ oVoucherDef -> GetMLTIdList ( 'shop_article_group_mlt' ) ; if ( count ( $ aArticleGroupRestrictons ) > 0 ) { $ aGroups = $ oArticle -> GetMLTIdList ( 'shop_article_group_mlt' ) ; $ aMatches = array_intersect ( $ aGroups , $ aArticleGroupRestrictons ) ; if ( 0 == count ( $ aMatches ) ) { $ bMayBeUsed = false ; } } } return $ bMayBeUsed ; }
return true if the voucher may be used for the article.

@param TShopBasketArticle $oArticle

@return bool
return true if the voucher may be used for the article .