예제 #1
0
 /**
  * Tests if total amount or price (price priority) of articles that can be applied to current discount fits to discount configuration
  *
  * @param oxbasket $oBasket basket
  *
  * @return bool
  */
 public function isForBasketAmount($oBasket)
 {
     $dAmount = 0;
     $aBasketItems = $oBasket->getContents();
     foreach ($aBasketItems as $oBasketItem) {
         $oBasketArticle = $oBasketItem->getArticle(false);
         $blForBasketItem = false;
         if ($this->oxdiscount__oxaddsumtype->value != 'itm') {
             $blForBasketItem = $this->isForBasketItem($oBasketArticle);
         } else {
             $blForBasketItem = $this->isForBundleItem($oBasketArticle);
         }
         if ($blForBasketItem) {
             $dRate = $oBasket->getBasketCurrency()->rate;
             if ($this->oxdiscount__oxprice->value) {
                 if ($oPrice = $oBasketArticle->getPrice()) {
                     $dAmount += $oPrice->getPrice() * $oBasketItem->getAmount() / $dRate;
                 }
             } elseif ($this->oxdiscount__oxamount->value) {
                 $dAmount += $oBasketItem->getAmount();
             }
         }
     }
     return $this->isForAmount($dAmount);
 }