Beispiel #1
0
 /**
  * Initialization coupons providers.
  *
  * @return void
  */
 protected static function initUseDiscount()
 {
     if (self::$onlySaleDiscount === null) {
         self::$onlySaleDiscount = (string) Option::get('sale', 'use_sale_discount_only') == 'Y';
         self::$couponProviders = array();
         if (!self::$onlySaleDiscount) {
             $eventData = array('COUPON_UNKNOWN' => Internals\DiscountCouponTable::TYPE_UNKNOWN, 'COUPON_TYPES' => array(Internals\DiscountCouponTable::TYPE_BASKET_ROW, Internals\DiscountCouponTable::TYPE_ONE_ORDER, Internals\DiscountCouponTable::TYPE_MULTI_ORDER));
             $event = new Main\Event('sale', self::EVENT_ON_BUILD_COUPON_PROVIDES, $eventData);
             $event->send();
             $resultList = $event->getResults();
             if (empty($resultList) || !is_array($resultList)) {
                 return;
             }
             foreach ($resultList as &$eventResult) {
                 if ($eventResult->getType() != Main\EventResult::SUCCESS) {
                     continue;
                 }
                 $module = (string) $eventResult->getModuleId();
                 $provider = $eventResult->getParameters();
                 if (empty($provider) || !is_array($provider)) {
                     continue;
                 }
                 if (empty($provider['getData']) || empty($provider['isExist']) || empty($provider['saveApplied'])) {
                     continue;
                 }
                 self::$couponProviders[] = array('module' => $module, 'getData' => $provider['getData'], 'isExist' => $provider['isExist'], 'saveApplied' => $provider['saveApplied'], 'mode' => isset($provider['mode']) && $provider['mode'] == self::COUPON_MODE_FULL ? self::COUPON_MODE_FULL : self::COUPON_MODE_SIMPLE);
             }
             unset($eventResult);
         }
     }
 }