Пример #1
0
 /**
  * Checks and sets voucher information. Checks it's availability according
  * to few conditions: oxvoucher::checkVoucherAvailability(),
  * oxvoucher::checkUserAvailability(). Errors are stored in
  * oxbasket::voucherErrors array. After all voucher is marked as reserved
  * (oxvoucher::MarkAsReserved())
  *
  * @param string $sVoucherId voucher ID
  *
  * @return null
  */
 public function addVoucher($sVoucherId)
 {
     // calculating price to check
     // P using prices sum which has discount, not sum of skipped discounts
     $dPrice = 0;
     if ($this->_oDiscountProductsPriceList) {
         $dPrice = $this->_oDiscountProductsPriceList->getBruttoSum();
     }
     try {
         // trying to load voucher and apply it
         $oVoucher = oxNew('oxvoucher');
         if (!$this->_blSkipVouchersAvailabilityChecking) {
             $oVoucher->getVoucherByNr($sVoucherId, $this->_aVouchers, true);
             $oVoucher->checkVoucherAvailability($this->_aVouchers, $dPrice);
             $oVoucher->checkUserAvailability($this->getBasketUser());
             $oVoucher->markAsReserved();
         } else {
             $oVoucher->load($sVoucherId);
         }
         // saving voucher info
         $this->_aVouchers[$oVoucher->oxvouchers__oxid->value] = $oVoucher->getSimpleVoucher();
     } catch (oxVoucherException $oEx) {
         // problems adding voucher
         oxUtilsView::getInstance()->addErrorToDisplay($oEx, false, true);
     }
     $this->onUpdate();
 }