Пример #1
0
 /**
  * Only token per cart setting
  *
  * @param OnlineShop_Framework_ICart $cart
  *
  * @throws Exception
  */
 protected function checkOnlyToken(OnlineShop_Framework_ICart $cart)
 {
     $cartCodes = $cart->getVoucherTokenCodes();
     $cartVoucherCount = sizeof($cartCodes);
     if ($cartVoucherCount && method_exists($this->configuration, 'getOnlyTokenPerCart')) {
         if ($this->configuration->getOnlyTokenPerCart()) {
             throw new OnlineShop_Framework_Exception_VoucherServiceException("OnlyTokenPerCart: This token is only allowed as only token in this cart.", 6);
         }
         $cartToken = OnlineShop_Framework_VoucherService_Token::getByCode($cartCodes[0]);
         $cartTokenSettings = Object_OnlineShopVoucherSeries::getById($cartToken->getVoucherSeriesId())->getTokenSettings()->getItems()[0];
         if ($cartTokenSettings->getOnlyTokenPerCart()) {
             throw new OnlineShop_Framework_Exception_VoucherServiceException("OnlyTokenPerCart: There is a token of type onlyToken in your this cart already.", 7);
         }
     }
 }
Пример #2
0
 protected function applyVoucherTokens(OnlineShop_Framework_AbstractOrder $order, OnlineShop_Framework_ICart $cart)
 {
     $voucherTokens = $cart->getVoucherTokenCodes();
     if (is_array($voucherTokens)) {
         $service = OnlineShop_Framework_Factory::getInstance()->getVoucherService();
         foreach ($voucherTokens as $code) {
             $service->applyToken($code, $cart, $order);
         }
     }
 }