Esempio n. 1
0
     if (isset($_REQUEST["COUPON"])) {
         $COUPON = (string) $_REQUEST['COUPON'];
         if ($COUPON === '') {
             DiscountCouponsManager::clear(true);
         } else {
             $arCoupons = array();
             $cupons = explode(",", $COUPON);
             foreach ($cupons as $val) {
                 $val = trim($val);
                 if ($val != '') {
                     $arCoupons[] = $val;
                 }
             }
             if (!empty($arCoupons)) {
                 foreach ($arCoupons as $oneCoupon) {
                     DiscountCouponsManager::add($oneCoupon);
                 }
             }
         }
     }
 }
 /*
  * register user if to order basket
  */
 if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["BasketOrder"]) and !$USER->IsAuthorized()) {
     if (strlen($payerEMail) <= 0) {
         $errorMessage .= GetMessage("STOF_ERROR_REG_EMAIL") . "<br>";
     } elseif (!check_email($payerEMail)) {
         $errorMessage .= GetMessage("STOF_ERROR_REG_BAD_EMAIL") . "<br>";
     }
     $pos = strpos($payerEMail, "@");
Esempio n. 2
0
 public function recalculateBasket($arPost)
 {
     global $USER;
     $arRes = array();
     if ($this->hideCoupon != "Y") {
         if (!empty($arPost['delete_coupon'])) {
             $arRes['VALID_COUPON'] = DiscountCouponsManager::delete($arPost['delete_coupon']);
         } else {
             $oldUse = false;
             if (array_key_exists('coupon', $arPost)) {
                 $arPost['coupon'] = trim((string) $arPost['coupon']);
                 if ($arPost['coupon'] != '') {
                     $arRes['VALID_COUPON'] = DiscountCouponsManager::add($arPost['coupon']);
                 } else {
                     $oldUse = true;
                 }
             }
             if ($oldUse) {
                 if (!isset($arRes["VALID_COUPON"]) || $arRes["VALID_COUPON"] === false) {
                     DiscountCouponsManager::clear(true);
                 }
             }
         }
     }
     $arTmpItems = array();
     $dbItems = CSaleBasket::GetList(array("PRICE" => "DESC"), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL"), false, false, array("ID", "NAME", "PRODUCT_PROVIDER_CLASS", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "CURRENCY", "SUBSCRIBE", "TYPE", "SET_PARENT_ID", "NOTES"));
     while ($arItem = $dbItems->Fetch()) {
         if (CSaleBasketHelper::isSetItem($arItem)) {
             continue;
         }
         $arTmpItems[] = $arItem;
     }
     if (!empty($arTmpItems)) {
         if (self::$catalogIncluded === null) {
             self::$catalogIncluded = Loader::includeModule('catalog');
         }
         if (self::$catalogIncluded) {
             $arTmpItems = getRatio($arTmpItems);
         }
         foreach ($arTmpItems as $arItem) {
             $isFloatQuantity = isset($arItem["MEASURE_RATIO"]) && floatval($arItem["MEASURE_RATIO"]) > 0 && $arItem["MEASURE_RATIO"] != 1 || $this->quantityFloat == "Y" ? true : false;
             if (!isset($arPost["QUANTITY_" . $arItem["ID"]]) || floatval($arPost["QUANTITY_" . $arItem["ID"]]) <= 0) {
                 $quantityTmp = $isFloatQuantity === true ? floatval($arItem["QUANTITY"]) : intval($arItem["QUANTITY"]);
             } else {
                 $quantityTmp = $isFloatQuantity === true ? floatval($arPost["QUANTITY_" . $arItem["ID"]]) : intval($arPost["QUANTITY_" . $arItem["ID"]]);
             }
             $deleteTmp = $arPost["DELETE_" . $arItem["ID"]] == "Y" ? "Y" : "N";
             $delayTmp = $arPost["DELAY_" . $arItem["ID"]] == "Y" ? "Y" : "N";
             if ($arItem["CAN_BUY"] == "Y") {
                 $res = $this->checkQuantity($arItem, $quantityTmp);
                 if (!empty($res)) {
                     $arRes["WARNING_MESSAGE"][] = $res["ERROR"];
                 }
             }
             if ($deleteTmp == "Y" && in_array("DELETE", $this->columns)) {
                 if ($arItem["SUBSCRIBE"] == "Y" && is_array($_SESSION["NOTIFY_PRODUCT"][$USER->GetID()])) {
                     unset($_SESSION["NOTIFY_PRODUCT"][$USER->GetID()][$arItem["PRODUCT_ID"]]);
                 }
                 CSaleBasket::Delete($arItem["ID"]);
             } elseif ($arItem["DELAY"] == "N" && $arItem["CAN_BUY"] == "Y") {
                 $arFields = array();
                 if (in_array("QUANTITY", $this->columns)) {
                     $arFields["QUANTITY"] = $quantityTmp;
                 }
                 if (in_array("DELAY", $this->columns)) {
                     $arFields["DELAY"] = $delayTmp;
                 }
                 if (!empty($arFields) && ($arItem["QUANTITY"] != $arFields["QUANTITY"] && in_array("QUANTITY", $this->columns) || $arItem["DELAY"] != $arFields["DELAY"] && in_array("DELAY", $this->columns))) {
                     CSaleBasket::Update($arItem["ID"], $arFields);
                 }
             } elseif ($arItem["DELAY"] == "Y" && $arItem["CAN_BUY"] == "Y") {
                 $arFields = array();
                 if (in_array("DELAY", $this->columns)) {
                     $arFields["DELAY"] = $delayTmp;
                 }
                 if (!empty($arFields) && ($arItem["DELAY"] != $arFields["DELAY"] && in_array("DELAY", $this->columns))) {
                     CSaleBasket::Update($arItem["ID"], $arFields);
                 }
             }
         }
     }
     return $arRes;
 }
Esempio n. 3
0
		$couponManagerMode = ($id > 0 ? DiscountCouponsManager::MODE_ORDER : DiscountCouponsManager::MODE_MANAGER);
		$couponManagerParams = array(
			'userId' => $user_id
		);
		if ($id > 0)
			$couponManagerParams['orderId'] = $id;
		DiscountCouponsManager::init($couponManagerMode, $couponManagerParams, false);
		unset($couponManagerParams, $couponManagerMode);
		$newCoupons = array();
		if (!empty($_REQUEST['coupon']))
			$newCoupons = fGetCoupon($_REQUEST['coupon']);
		if (!empty($newCoupons))
		{
			foreach ($newCoupons as &$oneCoupon)
			{
				$resultCoupon = DiscountCouponsManager::add($oneCoupon);
			}
			unset($resultCoupon, $oneCoupon);
		}
		unset($newCoupons);
		if (!empty($_REQUEST['deleteCoupon']))
		{
			$resultCoupon = DiscountCouponsManager::delete($_REQUEST['deleteCoupon']);
			unset($resultCoupon);
		}
		$arOrderProduct = CUtil::JsObjectToPhp($product);

		$arOrderOptions = array(
			'CART_FIX' => $cartFix
		);
Esempio n. 4
0
 /**
  * Updates information about basket products after changes have been made in the order_new form
  * (saves newly added basket items, changes their quantity, saves barcodes etc)
  *
  * @param int $orderId - order ID
  * @param string $siteId - site ID
  * @param bool $userId - user ID
  * @param array $arShoppingCart - array of basket items
  * @param array $arErrors
  * @param array $arCoupons
  * @param array $arStoreBarcodeOrderFormData - array of stores and barcodes for deduction (from order_new form)
  * @param bool $bSaveBarcodes - flat to save given barcode data. Used if the order is already deducted or at least has saved other barcodes
  * @return bool
  */
 public static function DoSaveOrderBasket($orderId, $siteId, $userId, &$arShoppingCart, &$arErrors, $arCoupons = array(), $arStoreBarcodeOrderFormData = array(), $bSaveBarcodes = false)
 {
     global $DB, $USER;
     $currentUserID = 0;
     if (isset($USER) && $USER instanceof CUser) {
         $currentUserID = (int) $USER->GetID();
     }
     if (defined("SALE_DEBUG") && SALE_DEBUG) {
         CSaleHelper::WriteToLog("DoSaveOrderBasket - Started", array("orderId" => $orderId, "siteId" => $siteId, "userId" => $userId, "arShoppingCart" => $arShoppingCart, "bSaveBarcodes" => $bSaveBarcodes, "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData), "DSOB1");
     }
     $orderId = (int) $orderId;
     if ($orderId <= 0) {
         return false;
     }
     if (empty($arShoppingCart) || !is_array($arShoppingCart)) {
         $arErrors[] = array("CODE" => "PARAM", "TEXT" => Loc::getMessage('SKGB_SHOPPING_CART_EMPTY'));
         return false;
     }
     $isOrderReserved = false;
     $isOrderDeducted = false;
     $dbOrderTmp = CSaleOrder::GetList(array(), array("ID" => $orderId), false, false, array("ID", "RESERVED", "DEDUCTED"));
     if ($arOrder = $dbOrderTmp->Fetch()) {
         if ($arOrder["RESERVED"] == "Y") {
             $isOrderReserved = true;
         }
         if ($arOrder["DEDUCTED"] == "Y") {
             $isOrderDeducted = true;
         }
     }
     $arOldItems = array();
     $dbItems = CSaleBasket::GetList(array(), array("ORDER_ID" => $orderId), false, false, array("ID", "QUANTITY", "CANCEL_CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "PRODUCT_PROVIDER_CLASS", "RESERVED", "RESERVE_QUANTITY", "TYPE", "SET_PARENT_ID"));
     while ($arItem = $dbItems->Fetch()) {
         $arOldItems[$arItem["ID"]] = array("QUANTITY" => $arItem["QUANTITY"], "CANCEL_CALLBACK_FUNC" => $arItem["CANCEL_CALLBACK_FUNC"], "PRODUCT_PROVIDER_CLASS" => $arItem["PRODUCT_PROVIDER_CLASS"], "MODULE" => $arItem["MODULE"], "PRODUCT_ID" => $arItem["PRODUCT_ID"], "RESERVED" => $arItem["RESERVED"], "RESERVE_QUANTITY" => $arItem["RESERVE_QUANTITY"], "TYPE" => $arItem["TYPE"], "SET_PARENT_ID" => $arItem["SET_PARENT_ID"]);
     }
     if (!empty($arCoupons)) {
         if (!is_array($arCoupons)) {
             $arCoupons = array($arCoupons);
         }
         foreach (GetModuleEvents("sale", "OnSetCouponList", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($userId, $arCoupons, array()));
         }
         foreach ($arCoupons as &$coupon) {
             $couponResult = DiscountCouponsManager::add($coupon);
         }
         unset($coupon);
     }
     $arFUserListTmp = CSaleUser::GetList(array("USER_ID" => $userId));
     if (empty($arFUserListTmp)) {
         $arFields = array("=DATE_INSERT" => $DB->GetNowFunction(), "=DATE_UPDATE" => $DB->GetNowFunction(), "USER_ID" => $userId, "CODE" => md5(time() . randString(10)));
         $FUSER_ID = CSaleUser::_Add($arFields);
     } else {
         $FUSER_ID = $arFUserListTmp["ID"];
     }
     // re-sort basket data so newly added Set parents come before Set items (used to correctly add Set items to the table)
     usort($arShoppingCart, array("CSaleBasketHelper", "cmpSetData"));
     foreach ($arShoppingCart as &$arItem) {
         $arItemKeys = array_keys($arItem);
         foreach ($arItemKeys as $fieldName) {
             if (array_key_exists("~" . $fieldName, $arItem)) {
                 if (is_array($arItem["~" . $fieldName]) && !empty($arItem["~" . $fieldName]) || !is_array($arItem["~" . $fieldName]) && strlen($arItem["~" . $fieldName]) > 0) {
                     $arItem[$fieldName] = $arItem["~" . $fieldName];
                 }
                 unset($arItem["~" . $fieldName]);
             }
         }
         $arItem = array_filter($arItem, array("CSaleBasketHelper", "filterFields"));
     }
     unset($arItem);
     $arTmpSetParentId = array();
     foreach ($arShoppingCart as $arItem) {
         if (strpos($arItem["SET_PARENT_ID"], "tmp") !== false) {
             $arTmpSetParentId[$arItem["SET_PARENT_ID"]] = $arItem["SET_PARENT_ID"];
         }
     }
     // iterate over basket data to save it to basket or change quantity (and reserve/deduct accordingly)
     foreach ($arShoppingCart as &$arItem) {
         foreach ($arItem as $tmpKey => $tmpVal) {
             if (is_array($tmpVal) && !in_array($tmpKey, array("STORES", "CATALOG", "PROPS"))) {
                 $arItem[$tmpKey] = serialize($tmpVal);
             }
         }
         if (defined("SALE_DEBUG") && SALE_DEBUG) {
             CSaleHelper::WriteToLog("DoSaveOrderBasket - Item", array("arItem" => $arItem), "DSOB2");
         }
         if (array_key_exists("ID", $arItem) && (int) $arItem["ID"] > 0) {
             $arItem["ID"] = (int) $arItem["ID"];
             if (defined("SALE_DEBUG") && SALE_DEBUG) {
                 CSaleHelper::WriteToLog("DoSaveOrderBasket - Product #" . $arItem["ID"] . " already in the basket", array(), "DSOB3");
             }
             // product already in the basket, change quantity
             if (array_key_exists($arItem["ID"], $arOldItems)) {
                 if (!CSaleBasketHelper::isSetParent($arItem)) {
                     $arAdditionalParams = array("ORDER_ID" => $orderId, "USER_ID" => $userId, "SITE_ID" => $siteId);
                     $quantity = $arItem["QUANTITY"] - $arOldItems[$arItem["ID"]]["QUANTITY"];
                     $arAdditionalParams["CHECK_QUANTITY"] = $quantity > 0 ? "Y" : "N";
                     if ($quantity != 0) {
                         self::DoChangeProductQuantity($arItem, $quantity, $isOrderReserved, $isOrderDeducted, $arStoreBarcodeOrderFormData[$arItem["ID"]], $arAdditionalParams);
                     } else {
                         $arAdditionalParams['CHECK_QUANTITY'] = 'N';
                         self::DoChangeProductQuantity($arItem, $quantity, $isOrderReserved, $isOrderDeducted, $arStoreBarcodeOrderFormData[$arItem["ID"]], $arAdditionalParams);
                     }
                 }
                 unset($arOldItems[$arItem["ID"]]);
             } else {
                 if ($arItem["QUANTITY"] != 0 && !CSaleBasketHelper::isSetParent($arItem)) {
                     self::DoChangeProductQuantity($arItem, $arItem["QUANTITY"], $isOrderReserved, $isOrderDeducted, $arStoreBarcodeOrderFormData[$arItem["ID"]], array("ORDER_ID" => $orderId, "USER_ID" => $userId, "SITE_ID" => $siteId));
                 }
             }
             if (IntVal($arItem["FUSER_ID"]) <= 0) {
                 $arFuserItems = CSaleUser::GetList(array("USER_ID" => intval($userId)));
                 $arItem["FUSER_ID"] = $arFuserItems["ID"];
             }
             if (CSaleBasketHelper::isSetItem($arItem)) {
                 // quantity for set items will be changed when parent item is updated
                 unset($arItem["QUANTITY"]);
             }
             CSaleBasket::Update($arItem["ID"], array("ORDER_ID" => $orderId, "IGNORE_CALLBACK_FUNC" => "Y") + $arItem);
         } else {
             if (defined("SALE_DEBUG") && SALE_DEBUG) {
                 CSaleHelper::WriteToLog("DoSaveOrderBasket - new product in the basket", array(), "DSOB4");
             }
             unset($arItem["ID"]);
             /** @var $productProvider IBXSaleProductProvider */
             if ($productProvider = CSaleBasket::GetProductProvider($arItem)) {
                 $oldSetParentId = -1;
                 if (CSaleBasketHelper::isSetParent($arItem) && array_key_exists($arItem["SET_PARENT_ID"], $arTmpSetParentId)) {
                     $oldSetParentId = $arItem["SET_PARENT_ID"];
                     $arItem["MANUAL_SET_ITEMS_INSERTION"] = "Y";
                 }
                 if (CSaleBasketHelper::isSetItem($arItem) && array_key_exists($arItem["SET_PARENT_ID"], $arTmpSetParentId)) {
                     $arItem["SET_PARENT_ID"] = $arTmpSetParentId[$arItem["SET_PARENT_ID"]];
                 }
                 $arItem["ID"] = CSaleBasket::Add(array("ORDER_ID" => $orderId, "IGNORE_CALLBACK_FUNC" => "Y") + $arItem);
                 if (isset($arItem["MANUAL_SET_ITEMS_INSERTION"])) {
                     $arTmpSetParentId[$oldSetParentId] = $arItem["ID"];
                 }
                 if ($bSaveBarcodes) {
                     if ($arItem["BARCODE_MULTI"] == "N") {
                         if (is_array($arItem["STORES"])) {
                             foreach ($arItem["STORES"] as $arStore) {
                                 $arStoreBarcodeFields = array("BASKET_ID" => $arItem["ID"], "BARCODE" => "", "STORE_ID" => $arStore["STORE_ID"], "QUANTITY" => $arStore["QUANTITY"], "CREATED_BY" => $currentUserID > 0 ? $currentUserID : '', "MODIFIED_BY" => $currentUserID > 0 ? $currentUserID : '');
                                 CSaleStoreBarcode::Add($arStoreBarcodeFields);
                             }
                         }
                     } else {
                         if (!empty($arItem["STORES"]) && is_array($arItem["STORES"])) {
                             foreach ($arItem["STORES"] as $arStore) {
                                 if (isset($arStore["BARCODE"]) && isset($arStore["BARCODE_FOUND"])) {
                                     foreach ($arStore["BARCODE"] as $barcodeId => $barcodeValue) {
                                         // save only non-empty and valid barcodes TODO - if errors?
                                         if (strlen($barcodeValue) > 0 && $arStore["BARCODE_FOUND"][$barcodeId] == "Y") {
                                             $arStoreBarcodeFields = array("BASKET_ID" => $arItem["ID"], "BARCODE" => $barcodeValue, "STORE_ID" => $arStore["STORE_ID"], "QUANTITY" => 1, "CREATED_BY" => $currentUserID > 0 ? $currentUserID : '', "MODIFIED_BY" => $currentUserID > 0 ? $currentUserID : '');
                                             CSaleStoreBarcode::Add($arStoreBarcodeFields);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($arItem["QUANTITY"] != 0 && !CSaleBasketHelper::isSetParent($arItem)) {
                     self::DoChangeProductQuantity($arItem, $arItem["QUANTITY"], $isOrderReserved, $isOrderDeducted, $arItem["STORES"], array("ORDER_ID" => $orderId, "USER_ID" => $userId, "SITE_ID" => $siteId));
                 }
                 if ($FUSER_ID > 0) {
                     $arItem["FUSER_ID"] = $FUSER_ID;
                 }
             } else {
                 if ($arItem["QUANTITY"] != 0 && !CSaleBasketHelper::isSetParent($arItem)) {
                     self::DoChangeProductQuantity($arItem, $arItem["QUANTITY"], $isOrderReserved, $isOrderDeducted, $arItem["STORES"], array("ORDER_ID" => $orderId, "USER_ID" => $userId, "SITE_ID" => $siteId));
                 }
                 if ($FUSER_ID > 0) {
                     $arItem["FUSER_ID"] = $FUSER_ID;
                 }
                 $arItem["ID"] = CSaleBasket::Add(array("ORDER_ID" => $orderId, "IGNORE_CALLBACK_FUNC" => "Y") + $arItem);
                 //$arItem["ID"] = CSaleBasket::Add(array("CALLBACK_FUNC" => false, "ORDER_ID" => $orderId, "IGNORE_CALLBACK_FUNC" => "Y") + $arItem);
             }
         }
     }
     unset($arItem);
     if (defined("SALE_DEBUG") && SALE_DEBUG) {
         CSaleHelper::WriteToLog("Items left in the old basket:", array("arOldItems" => $arOldItems), "DSOB5");
     }
     // if some items left in the table which are not present in the updated basket, delete them
     $arSetParentsIDs = array();
     foreach ($arOldItems as $key => $arOldItem) {
         $arOldItem["ID"] = $key;
         if (CSaleBasketHelper::isSetParent($arOldItem)) {
             $arSetParentsIDs[] = $arOldItem["ID"];
             continue;
         } else {
             // the quantity is negative, so the product is canceled
             self::DoChangeProductQuantity($arOldItem, -$arOldItem["QUANTITY"], $isOrderReserved, $isOrderDeducted, $arStoreBarcodeOrderFormData[$arOldItem["ID"]], array("ORDER_ID" => $orderId, "USER_ID" => $userId, "SITE_ID" => $siteId));
         }
         CSaleBasket::Delete($key);
     }
     foreach ($arSetParentsIDs as $setParentID) {
         CSaleBasket::Delete($setParentID);
     }
     foreach (GetModuleEvents("sale", "OnDoBasketOrder", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($orderId));
     }
     return true;
 }
Esempio n. 5
0
 protected function addCouponsAction()
 {
     if (!isset($this->request["userId"])) {
         throw new ArgumentNullException("userId");
     }
     if (!isset($this->request["coupon"])) {
         throw new ArgumentNullException("coupon");
     }
     if (!isset($this->request["orderId"])) {
         throw new ArgumentNullException("orderId");
     }
     Admin\OrderEdit::initCouponsData($this->request["userId"], $this->request["orderId"]);
     if (strlen($this->request["coupon"]) > 0) {
         $coupons = explode(",", $this->request["coupon"]);
         if (is_array($coupons) && count($coupons) > 0) {
             foreach ($coupons as $coupon) {
                 if (strlen($coupon) > 0) {
                     Sale\DiscountCouponsManager::add($coupon);
                 }
             }
         }
     }
     $this->addResultData('RESULT', 'OK');
 }
Esempio n. 6
0
 public static function saveCoupons($userId, $formData)
 {
     if (intval($userId) <= 0) {
         return false;
     }
     // init discount coupons
     DiscountCouponsManager::init(DiscountCouponsManager::MODE_MANAGER, array("userId" => $userId));
     if (!DiscountCouponsManager::isSuccess()) {
         throw new UserMessageException(print_r(DiscountCouponsManager::getErrors(), true));
     }
     if (isset($formData["COUPONS"]) && strlen($formData["COUPONS"]) > 0) {
         $coupons = explode(",", $formData["COUPONS"]);
         if (is_array($coupons) && count($coupons) > 0) {
             foreach ($coupons as $coupon) {
                 DiscountCouponsManager::add($coupon);
             }
         }
     }
     return true;
 }
Esempio n. 7
0
 /**
  * @deprecated deprecated since catalog 15.0.4
  * @see \Bitrix\Sale\DiscountCouponsManager
  *
  * @param int $intUserID				User id.
  * @param array $arCoupons			Coupon code list.
  * @param array $arModules			Modules list.
  * @return bool
  */
 public static function OnSetCouponList($intUserID, $arCoupons, $arModules)
 {
     global $USER;
     $boolResult = false;
     if (empty($arModules) || is_array($arModules) && in_array('catalog', $arModules)) {
         if (!empty($arCoupons)) {
             if (!is_array($arCoupons)) {
                 $arCoupons = array($arCoupons);
             }
             $intUserID = (int) $intUserID;
             if (self::$existCouponsManager === null) {
                 self::initCouponManager();
             }
             if (self::$existCouponsManager) {
                 if ($intUserID == DiscountCouponsManager::getUserId()) {
                     foreach ($arCoupons as &$coupon) {
                         if (DiscountCouponsManager::add($coupon)) {
                             $boolResult = true;
                         }
                     }
                     unset($coupon);
                     return $boolResult;
                 }
                 return false;
             } else {
                 if ($intUserID > 0) {
                     $boolCurrentUser = $USER->IsAuthorized() && $intUserID == $USER->GetID();
                     foreach ($arCoupons as &$strOneCoupon) {
                         if (self::SetCouponByManage($intUserID, $strOneCoupon)) {
                             $boolResult = true;
                         }
                         if ($boolCurrentUser) {
                             self::SetCoupon($strOneCoupon);
                         }
                     }
                     unset($strOneCoupon);
                 } elseif (0 == $intUserID && !$USER->IsAuthorized()) {
                     foreach ($arCoupons as &$strOneCoupon) {
                         $couponResult = self::SetCoupon($strOneCoupon);
                         if ($couponResult) {
                             $boolResult = true;
                         }
                     }
                     unset($strOneCoupon);
                 }
             }
         }
     }
     return $boolResult;
 }