/** * Function performs a conversion between a shared cache and the particular structure of our $arResult * @param mixed[] $cached Cached data taken from obtainDataReferences() * @return mixed[] Data structure that is appropriate for our $arResult */ protected function adaptCachedReferences($cached) { $formed = array(); // form person type $formed["PERSON_TYPE"] = $cached['PERSON_TYPE'][$this->dbResult["PERSON_TYPE_ID"]]; // form status $formed['STATUS'] = $cached['STATUS'][$this->dbResult["STATUS_ID"]]; // form delivery foreach ($this->dbResult['SHIPMENT'] as $shipment) { $shipment['DELIVERY'] = $cached['DELIVERY'][$shipment["DELIVERY_ID"]]; $shipment['DELIVERY']['STORE'] = \Bitrix\Sale\Delivery\ExtraServices\Manager::getStoresList($shipment["DELIVERY_ID"]); $formed['SHIPMENT'][] = $shipment; } $formed['DELIVERY'] = $formed['SHIPMENT'][0]['DELIVERY']; return $formed; }
protected static function getStoresList($deliveryId) { $result = array(); if (!\Bitrix\Main\Loader::includeModule('catalog')) { return $result; } $storesIds = \Bitrix\Sale\Delivery\ExtraServices\Manager::getStoresList($deliveryId); if (!empty($storesIds)) { $dbList = \CCatalogStore::GetList(array("SORT" => "DESC", "ID" => "DESC"), array("ACTIVE" => "Y", "ISSUING_CENTER" => "Y", "ID" => $storesIds), false, false, array("ID", "SITE_ID", "TITLE", "ADDRESS", "DESCRIPTION", "IMAGE_ID", "PHONE", "SCHEDULE", "LOCATION_ID", "GPS_N", "GPS_S")); while ($store = $dbList->Fetch()) { $result[$store["ID"]] = $store; } } return $result; }
/** * @param array $arOrder * @param array $arFilter * @param bool $arGroupBy * @param bool $arNavStartParams * @param array $arSelectFields * @return \CDBResult * @throws \Bitrix\Main\ArgumentException * @deprecated */ public static function GetList($arOrder = array("SORT" => "ASC", "NAME" => "ASC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array('*')) { if (empty($arSelectFields)) { $arSelectFields = array('*'); } $params = array('order' => $arOrder, 'filter' => self::convertFilterOldToNew($arFilter), 'group' => self::convertGroupOldToNew($arGroupBy), 'select' => self::convertSelectOldToNew($arSelectFields)); $services = array(); $params['filter']['=CLASS_NAME'] = '\\Bitrix\\Sale\\Delivery\\Services\\Configurable'; $dbRes = \Bitrix\Sale\Delivery\Services\Table::getList($params); if (isset($arFilter["WEIGHT"]) && DoubleVal($arFilter["WEIGHT"]) > 0) { if (!isset($arFilter["WEIGHT_FROM"]) || floatval($arFilter["WEIGHT"]) > floatval($arFilter["WEIGHT_FROM"])) { $arFilter["+<=WEIGHT_FROM"] = $arFilter["WEIGHT"]; } if (!isset($arFilter["WEIGHT_TO"]) || floatval($arFilter["WEIGHT"]) < floatval($arFilter["WEIGHT_TO"])) { $arFilter["+>=WEIGHT_TO"] = $arFilter["WEIGHT"]; } } if (isset($arFilter["ORDER_PRICE"]) && IntVal($arFilter["ORDER_PRICE"]) > 0) { if (!isset($arFilter["ORDER_PRICE_FROM"]) || floatval($arFilter["ORDER_PRICE"]) > floatval($arFilter["ORDER_PRICE_FROM"])) { $arFilter["+<=ORDER_PRICE_FROM"] = $arFilter["ORDER_PRICE"]; } if (!isset($arFilter["ORDER_PRICE_TO"]) || floatval($arFilter["ORDER_PRICE"]) < floatval($arFilter["ORDER_PRICE_TO"])) { $arFilter["+>=ORDER_PRICE_TO"] = $arFilter["ORDER_PRICE"]; } } while ($service = $dbRes->fetch()) { $dbRstrRes = \Bitrix\Sale\Delivery\Restrictions\Table::getList(array('filter' => array("=DELIVERY_ID" => $service["ID"]))); while ($restr = $dbRstrRes->fetch()) { if (!self::checkRestrictionFilter($restr, $arFilter)) { continue 2; } $service = self::getSelectedRestrictionField($service, $restr, $arSelectFields); } $selectAsterisk = in_array('*', $arSelectFields); $mofifiedFields = array("LID", "WEIGHT_FROM", "WEIGHT_TO", "ORDER_PRICE_FROM", "ORDER_PRICE_TO", "ORDER_CURRENCY"); foreach ($mofifiedFields as $field) { if (($selectAsterisk || in_array($field, $arSelectFields)) && !array_key_exists($field, $service)) { $service[$field] = ""; } } if ($selectAsterisk || in_array("PERIOD_FROM", $arSelectFields)) { $service["PERIOD_FROM"] = $service["CONFIG"]["MAIN"]["PERIOD"]["FROM"]; } if ($selectAsterisk || in_array("PERIOD_TO", $arSelectFields)) { $service["PERIOD_TO"] = $service["CONFIG"]["MAIN"]["PERIOD"]["TO"]; } if ($selectAsterisk || in_array("PERIOD_TYPE", $arSelectFields)) { $service["PERIOD_TYPE"] = $service["CONFIG"]["MAIN"]["PERIOD"]["TYPE"]; } if ($selectAsterisk || in_array("PRICE", $arSelectFields)) { $service["CLASS_NAME"] = '\\Bitrix\\Sale\\Delivery\\Services\\Configurable'; $tmpSrv = \Bitrix\Sale\Delivery\Services\Manager::createServiceObject($service); $res = $tmpSrv->calculate(); $service["PRICE"] = $res->getPrice(); } if ($selectAsterisk || in_array("STORE", $arSelectFields)) { $stores = \Bitrix\Sale\Delivery\ExtraServices\Manager::getStoresList($service["ID"]); $service["STORE"] = count($stores) > 0 ? serialize($stores) : ""; } if (intval($service["CODE"]) > 0) { $service["ID"] = $service["CODE"]; } unset($service["CODE"], $service["CLASS_NAME"], $service["CONFIG"], $service["PARENT_ID"]); $services[] = $service; } $result = new \CDBResult(); $result->InitFromArray($services); return $result; }
$arDelivery["PERIOD_TEXT"] = $calcResult->getPeriodDescription(); } $arResult["DELIVERY_PRICE"] = roundEx($calcResult->getPrice(), SALE_VALUE_PRECISION); } elseif (count($calcResult->getErrorMessages()) > 0) { foreach ($calcResult->getErrorMessages() as $message) { $arDelivery["CALCULATE_ERRORS"] .= $message . '<br>'; } } else { $arDelivery = GetMessage("SOA_DELIVERY_CALCULATE_ERROR"); } } if (intval($deliveryObj->logotip) > 0) { $arDelivery["LOGOTIP"] = CFile::GetFileArray($deliveryObj->logotip); } $arDelivery['EXTRA_SERVICES'] = $deliveryObj->getExtraServices()->getItems(); $arDelivery['STORE'] = \Bitrix\Sale\Delivery\ExtraServices\Manager::getStoresList($deliveryObj->getId()); $arDelivery['SORT'] = $deliveryObj->sort; $arResult["DELIVERY"][$deliveryObj->id] = $arDelivery; $bFirst = false; if (isset($_POST["BUYER_STORE"]) && !empty($arDelivery['STORE']) && is_array($arDelivery['STORE']) && in_array($_POST["BUYER_STORE"], $arDelivery['STORE'])) { $arUserResult['DELIVERY_STORE'] = $arDelivery["ID"]; } } } uasort($arResult["DELIVERY"], array('CSaleBasketHelper', 'cmpBySort')); // resort delivery arrays according to SORT value //If none delivery service was selected let's select the first one. if (!$bSelected && !empty($arResult["DELIVERY"])) { reset($arResult["DELIVERY"]); $key = key($arResult["DELIVERY"]); $arResult["DELIVERY"][$key]["CHECKED"] = "Y";