44 public function __construct( $sObjectsInListName =
'oxdiscount' )
72 $sUserId = $oUser?$oUser->getId():
'';
74 if ( $this->_blReload || $sUserId !== $this->_sUserId ) {
79 $this->_blReload =
false;
80 $this->_sUserId = $sUserId;
100 $sCountryId = $oUser->getActiveCountry();
113 $this->_blReload =
true;
127 $sTable = $oBaseObject->getViewName();
128 $sQ =
"select ".$oBaseObject->getSelectFields().
" from $sTable ";
129 $sQ .=
"where ".$oBaseObject->getSqlActiveSnippet().
' ';
142 $sUserId = $oUser->getId();
145 foreach ( $oUser->getUserGroups() as $oGroup ) {
149 $sGroupIds .= $oDb->quote( $oGroup->getId() );
153 $sUserTable = getViewName(
'oxuser' );
154 $sGroupTable = getViewName(
'oxgroups' );
155 $sCountryTable = getViewName(
'oxcountry' );
157 $sCountrySql = $sCountryId?
"EXISTS(select oxobject2discount.oxid from oxobject2discount where oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxcountry' and oxobject2discount.OXOBJECTID=".$oDb->quote( $sCountryId ).
")":
'0';
158 $sUserSql = $sUserId ?
"EXISTS(select oxobject2discount.oxid from oxobject2discount where oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxuser' and oxobject2discount.OXOBJECTID=".$oDb->quote( $sUserId ).
")":
'0';
159 $sGroupSql = $sGroupIds ?
"EXISTS(select oxobject2discount.oxid from oxobject2discount where oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxgroups' and oxobject2discount.OXOBJECTID in ($sGroupIds) )":
'0';
163 if(EXISTS(select 1 from oxobject2discount, $sCountryTable where $sCountryTable.oxid=oxobject2discount.oxobjectid and oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxcountry' LIMIT 1),
166 if(EXISTS(select 1 from oxobject2discount, $sUserTable where $sUserTable.oxid=oxobject2discount.oxobjectid and oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxuser' LIMIT 1),
169 if(EXISTS(select 1 from oxobject2discount, $sGroupTable where $sGroupTable.oxid=oxobject2discount.oxobjectid and oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxgroups' LIMIT 1),
188 $aDiscList = $this->
_getList( $oUser )->getArray();
189 foreach ( $aDiscList as $oDiscount ) {
190 if ( $oDiscount->isForArticle( $oArticle ) ) {
191 $aList[$oDiscount->getId()] = $oDiscount;
210 $aDiscList = $this->
_getList( $oUser )->getArray();
211 foreach ( $aDiscList as $oDiscount ) {
212 if ( $oDiscount->isForBasketItem( $oArticle ) && $oDiscount->isForBasketAmount( $oBasket ) ) {
213 $aList[$oDiscount->getId()] = $oDiscount;
231 $aDiscList = $this->
_getList( $oUser )->getArray();
232 foreach ( $aDiscList as $oDiscount ) {
233 if ( $oDiscount->isForBasket( $oBasket ) ) {
234 $aList[$oDiscount->getId()] = $oDiscount;
253 $aDiscList = $this->
_getList( $oUser )->getArray();
254 foreach ( $aDiscList as $oDiscount ) {
255 if ( $oDiscount->isForBundleItem( $oArticle, $oBasket ) && $oDiscount->isForBasketAmount($oBasket) ) {
256 $aList[$oDiscount->getId()] = $oDiscount;
274 $aDiscList = $this->
_getList( $oUser )->getArray();
275 foreach ( $aDiscList as $oDiscount ) {
276 if ( $oDiscount->isForBundleBasket( $oBasket ) ) {
277 $aList[$oDiscount->getId()] = $oDiscount;
296 reset( $aDiscounts );
297 while ( list( , $oDiscount ) = each( $aDiscounts ) ) {
298 $oDiscount->applyDiscount( $oPrice );
317 reset( $aDiscounts );
322 while (list( , $oDiscount ) = each( $aDiscounts ) ) {
323 $oDiscount->applyDiscount( $oPrice );
326 if ( !isset( $aDiscLog[$oDiscount->getId()] ) ) {
327 $aDiscLog[$oDiscount->getId()] = $oDiscount->getSimpleDiscount();
330 $aDiscLog[$oDiscount->getId()]->dDiscount += $dOldPrice - $dNewPrice;
331 $aDiscLog[$oDiscount->getId()]->dDiscount *= $dAmount;
332 $dOldPrice = $dNewPrice;
345 if ( $this->_hasSkipDiscountCategories === null || $this->_blReload ) {
346 $sViewName = getViewName(
'oxcategories' );
347 $sQ =
"select 1 from {$sViewName} where {$sViewName}.oxactive = 1 and {$sViewName}.oxskipdiscounts = '1' ";
349 $this->_hasSkipDiscountCategories = (bool)
oxDb::getDb()->getOne( $sQ );