$arFilter["ID"][] = $val[$arUserResult["DELIVERY_ID"]];
         }
     }
 }
 if ($arParams["DELIVERY_TO_PAYSYSTEM"] == "p2d") {
     $arD2P = array();
 }
 if ($arUserResult["PREPAYMENT_MODE"] && IntVal($arUserResult["PAY_SYSTEM_ID"]) > 0) {
     $arFilter["ID"] = $arUserResult["PAY_SYSTEM_ID"];
 }
 $bFirst = True;
 $dbPaySystem = CSalePaySystem::GetList(array("SORT" => "ASC", "PSA_NAME" => "ASC"), $arFilter);
 while ($arPaySystem = $dbPaySystem->Fetch()) {
     //if (count($arD2P[$delivery]) <= 0 || in_array($arPaySystem["ID"], $arD2P[$delivery]))
     //{
     if (strlen($arUserResult["DELIVERY_ID"]) <= 0 || $arParams["DELIVERY_TO_PAYSYSTEM"] == "p2d" || CSaleDelivery2PaySystem::isPaySystemApplicable($arPaySystem["ID"], $arUserResult["DELIVERY_ID"])) {
         if (!CSalePaySystemsHelper::checkPSCompability($arPaySystem["PSA_ACTION_FILE"], $arOrder, $arResult["ORDER_PRICE"], $arResult["DELIVERY_PRICE"], $arUserResult["DELIVERY_LOCATION"])) {
             continue;
         }
         if ($arPaySystem["PSA_LOGOTIP"] > 0) {
             $arPaySystem["PSA_LOGOTIP"] = CFile::GetFileArray($arPaySystem["PSA_LOGOTIP"]);
         }
         $arPaySystem["PSA_NAME"] = htmlspecialcharsEx($arPaySystem["PSA_NAME"]);
         $arResult["PAY_SYSTEM"][$arPaySystem["ID"]] = $arPaySystem;
         $arResult["PAY_SYSTEM"][$arPaySystem["ID"]]["PRICE"] = CSalePaySystemsHelper::getPSPrice($arPaySystem, $arResult["ORDER_PRICE"], $arResult["DELIVERY_PRICE"], $arUserResult["DELIVERY_LOCATION"]);
         if (IntVal($arUserResult["PAY_SYSTEM_ID"]) == IntVal($arPaySystem["ID"]) || IntVal($arUserResult["PAY_SYSTEM_ID"]) <= 0 && $bFirst) {
             //$arPaySystem["CHECKED"] = "Y";
             $arResult["PAY_SYSTEM"][$arPaySystem["ID"]]["CHECKED"] = "Y";
             $arUserResult["PAY_SYSTEM_ID"] = $arPaySystem["ID"];
         }
         $bFirst = false;
Beispiel #2
0
 public function getPaysystems($deliveryId = null)
 {
     if (empty($deliveryId)) {
         $deliveryId = $this->deliveryId;
     }
     if (empty($deliveryId)) {
         throw new \Exception('Для получения способов оплаты нужно указать службу доставки');
     }
     $paySystems = array();
     $paySystemFilter = array('ACTIVE' => 'Y', 'PERSON_TYPE_ID' => 1, 'PSA_HAVE_PAYMENT' => 'Y');
     $res = \CSalePaySystem::GetList(array("SORT" => "ASC", "PSA_NAME" => "ASC"), $paySystemFilter);
     while ($paySystem = $res->Fetch()) {
         if (!\CSaleDelivery2PaySystem::isPaySystemApplicable($paySystem['ID'], $deliveryId)) {
             continue;
         }
         $check = \CSalePaySystemsHelper::checkPSCompability($paySystem['PSA_ACTION_FILE'], $this->getItemsRaw(), $this->getTotal(), $this->deliveryPrice, $this->location);
         if (!$check) {
             continue;
         }
         $paySystem['PRICE'] = \CSalePaySystemsHelper::getPSPrice($paySystem, $this->getTotal(), $this->deliveryPrice, $this->location);
         $paySystems[] = $paySystem;
     }
     return $paySystems;
 }
Beispiel #3
0
		if($arUserResult["PREPAYMENT_MODE"] && IntVal($arUserResult["PAY_SYSTEM_ID"]) > 0)
			$arFilter["ID"] = $arUserResult["PAY_SYSTEM_ID"];

		$bFirst = True;
		$dbPaySystem = CSalePaySystem::GetList(
					array("SORT" => "ASC", "PSA_NAME" => "ASC"),
					$arFilter
			);

		while ($arPaySystem = $dbPaySystem->Fetch())
		{
			//if (count($arD2P[$delivery]) <= 0 || in_array($arPaySystem["ID"], $arD2P[$delivery]))
			//{
			if(strlen($arUserResult["DELIVERY_ID"]) <= 0
					|| $arParams["DELIVERY_TO_PAYSYSTEM"] == "p2d"
					|| CSaleDelivery2PaySystem::isPaySystemApplicable($arPaySystem["ID"], $arUserResult["DELIVERY_ID"])
					)
			{

				if(!CSalePaySystemsHelper::checkPSCompability(
																$arPaySystem["PSA_ACTION_FILE"],
																$arOrder,
																$arResult["ORDER_PRICE"],
																$arResult["DELIVERY_PRICE"],
																$arUserResult["DELIVERY_LOCATION"]
															))
				{
					continue;
				}

				if ($arPaySystem["PSA_LOGOTIP"] > 0)
	public function filterDeliveryAndPaySystems(&$arResult, &$arUserResult, $arParams) {
		if (CModule::IncludeModule(self::$MODULE_ID)) {
			if ($person_type_id = COption::GetOptionString(self::$MODULE_ID, 'person_type_id')) {
				if ($arUserResult['PERSON_TYPE_ID'] == $person_type_id) {
					// $filename1 = $_SERVER['DOCUMENT_ROOT'] . '/templogfilter.log';
					// $data1 = array('FLAG' => $_POST['gp_delivery_option_disabled_flag'], /*'arResult' => $arResult,*/'arUserResult' => $arUserResult, 'arParams' => $arParams);
					// file_put_contents($filename1, var_export($data1, true), FILE_APPEND | LOCK_EX);
					if (CModule::IncludeModule('sale')) {
						if (!empty($arResult['DELIVERY']['goparcel']) && !empty($_POST['gp_delivery_description'])) {
							$arResult['DELIVERY']['goparcel']['PROFILES']['simple']['DESCRIPTION'] = htmlspecialchars($_POST['gp_delivery_description']);
						}
						if ($arParams["DELIVERY_TO_PAYSYSTEM"] == "p2d") {
							if ($arUserResult['DELIVERY_ID'] == 'goparcel:simple') {
								foreach ($arResult['PAY_SYSTEM'] as $cell => $val) {
									$is_applicable = CSaleDelivery2PaySystem::isPaySystemApplicable($val['ID'], $arUserResult['DELIVERY_ID']);
									if (!$is_applicable) {
										unset($arResult['PAY_SYSTEM'][$cell]);
									}
								}
							}
						} else {
							$delivery = array();
							$d2psRes = CSaleDelivery2PaySystem::GetList();
							while ($d2psAr = $d2psRes->Fetch())
							{
								if (!($d2psAr['DELIVERY_ID'] == 'goparcel' && $d2psAr['DELIVERY_PROFILE_ID'] == 'simple') ||
									$d2psAr['PAYSYSTEM_ID'] == $arUserResult['PAY_SYSTEM_ID']) {
									if ($d2psAr['DELIVERY_PROFILE_ID']) {
										$delivery[$d2psAr['DELIVERY_ID']]["PROFILES"][$d2psAr['DELIVERY_PROFILE_ID']] = $d2psAr['PAYSYSTEM_ID'];
									} else {
										$delivery[$d2psAr['DELIVERY_ID']] = $d2psAr['PAYSYSTEM_ID'];
									}
								}
							}
							foreach ($arResult['DELIVERY'] as $cell => $val) {
								if ($val['ID'] && (!isset($delivery[$val['ID']]) || empty($delivery[$val['ID']]))) {
									unset($arResult['DELIVERY'][$cell]);
								} elseif ($val['SID'] && array_key_exists("PROFILES", $val)) {
									if (is_array($delivery[$val['SID']]) && array_key_exists("PROFILES", $delivery[$val['SID']])) {
										foreach ($val["PROFILES"] as $subcell => $profile) {
											if (!isset($delivery[$val['SID']]["PROFILES"][$profile['SID']]) || empty($delivery[$val['SID']]["PROFILES"][$profile['SID']])) {
												unset($arResult['DELIVERY'][$cell]["PROFILES"][$subcell]);
											}
										}
										if (count($arResult['DELIVERY'][$cell]["PROFILES"]) == 0) {
											unset($arResult['DELIVERY'][$cell]);
										}
									} else {
										unset($arResult['DELIVERY'][$cell]);
									}
								}
							}
						}
					}
				} else {
					if ($arUserResult['DELIVERY_ID'] == 'goparcel:simple') {
						$arUserResult['DELIVERY_ID'] = '';
					}
					unset($arResult['DELIVERY']['goparcel']);
				}
			}
		}
	}