本文整理汇总了PHP中CSaleDelivery::getIdByCode方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleDelivery::getIdByCode方法的具体用法?PHP CSaleDelivery::getIdByCode怎么用?PHP CSaleDelivery::getIdByCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleDelivery
的用法示例。
在下文中一共展示了CSaleDelivery::getIdByCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ShowError
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die;
}
if (!CModule::IncludeModule("sale")) {
ShowError(GetMessage("SALE_MODULE_NOT_INSTALL"));
return;
}
$arParams["AJAX_CALL"] = $arParams["AJAX_CALL"] == "Y" ? "Y" : "N";
$arParams["STEP"] = intval($arParams["STEP"]);
if (isset($arParams["DELIVERY"]) && isset($arParams["PROFILE"]) && !isset($arParams["DELIVERY_ID"])) {
$arParams["DELIVERY_ID"] = \CSaleDelivery::getIdByCode($arParams["DELIVERY"] . ":" . $arParams["PROFILE"]);
}
$arParams['NO_AJAX'] = $arParams['NO_AJAX'] == 'Y' ? 'Y' : 'N';
if ($arParams['NO_AJAX'] == 'Y') {
$arParams['AJAX_CALL'] = 'Y';
$arParams['STEP'] = 1;
}
if (!isset($arParams["ORDER_DATA"])) {
$arParams["ORDER_DATA"] = array();
}
if (!isset($arParams["EXTRA_PARAMS"])) {
$arParams["EXTRA_PARAMS"] = array();
}
$arParams["LOCATION_TO"] = intval($arParams["LOCATION_TO"]);
$arParams["LOCATION_FROM"] = intval($arParams["LOCATION_FROM"]);
if ($arParams["LOCATION_FROM"] <= 0) {
$arParams["LOCATION_FROM"] = COption::GetOptionString('sale', 'location');
}
$arParams["STEP"] = intval($arParams["STEP"]);
示例2: DoProcessOrder
public static function DoProcessOrder(&$arOrder, $arOptions, &$arErrors)
{
if (empty($arOrder['BASKET_ITEMS']) || !is_array($arOrder['BASKET_ITEMS'])) {
return;
}
$isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
$oldDelivery = '';
$checkIds = true;
$arIDS = array();
if ($isOrderConverted == 'Y') {
if (isset($arOrder['DELIVERY_ID']) && $arOrder['DELIVERY_ID'] != '') {
$oldDelivery = $arOrder['DELIVERY_ID'];
$arOrder['DELIVERY_ID'] = \CSaleDelivery::getIdByCode($arOrder['DELIVERY_ID']);
}
$adminSection = defined('ADMIN_SECTION') && ADMIN_SECTION === true;
if (!$adminSection) {
$mode = Sale\Compatible\DiscountCompatibility::MODE_MANAGER;
$modeParams = array();
if (isset($arOrder['CURRENCY'])) {
$modeParams['CURRENCY'] = $arOrder['CURRENCY'];
}
if (isset($arOrder['SITE_ID'])) {
$modeParams['SITE_ID'] = $arOrder['SITE_ID'];
if (!isset($modeParams['CURRENCY'])) {
$modeParams['CURRENCY'] = Sale\Internals\SiteCurrencyTable::getSiteCurrency($modeParams['SITE_ID']);
}
}
} else {
$mode = Sale\Compatible\DiscountCompatibility::MODE_CLIENT;
$modeParams = array('SITE_ID' => SITE_ID, 'CURRENCY' => Sale\Internals\SiteCurrencyTable::getSiteCurrency(SITE_ID));
}
unset($adminSection);
if (!empty($modeParams)) {
Sale\Discount\Actions::setUseMode(Sale\Discount\Actions::MODE_CALCULATE, array('USE_BASE_PRICE' => \Bitrix\Main\Config\Option::get('sale', 'get_discount_percent_from_base_price'), 'SITE_ID' => $modeParams['SITE_ID'], 'CURRENCY' => $modeParams['CURRENCY']));
}
if (!Sale\Compatible\DiscountCompatibility::isInited()) {
if (!empty($modeParams)) {
Sale\Compatible\DiscountCompatibility::init($mode, $modeParams);
}
}
unset($modeParams, $mode);
Sale\Compatible\DiscountCompatibility::clearDiscountResult();
Sale\Compatible\DiscountCompatibility::fillBasketData($arOrder['BASKET_ITEMS']);
Sale\Compatible\DiscountCompatibility::calculateBasketDiscounts($arOrder['BASKET_ITEMS']);
Sale\Compatible\DiscountCompatibility::setApplyMode($arOrder['BASKET_ITEMS']);
$applyMode = Sale\Discount::getApplyMode();
if ($applyMode == Sale\Discount::APPLY_MODE_FULL_LAST || $applyMode == Sale\Discount::APPLY_MODE_FULL_DISABLE) {
foreach ($arOrder['BASKET_ITEMS'] as &$basketItem) {
if (isset($basketItem['LAST_DISCOUNT']) && $basketItem['LAST_DISCOUNT'] == 'Y') {
$checkIds = false;
break;
}
}
unset($basketItem);
}
}
if ($checkIds) {
$groupDiscountIterator = Sale\Internals\DiscountGroupTable::getList(array('select' => array('DISCOUNT_ID'), 'filter' => array('@GROUP_ID' => CUser::GetUserGroup($arOrder['USER_ID']), '=ACTIVE' => 'Y')));
while ($groupDiscount = $groupDiscountIterator->fetch()) {
$groupDiscount['DISCOUNT_ID'] = (int) $groupDiscount['DISCOUNT_ID'];
if ($groupDiscount['DISCOUNT_ID'] > 0) {
$arIDS[$groupDiscount['DISCOUNT_ID']] = true;
}
}
}
if (!empty($arIDS)) {
$arIDS = array_keys($arIDS);
$couponList = Sale\DiscountCouponsManager::getForApply(array('MODULE_ID' => 'sale', 'DISCOUNT_ID' => $arIDS), array(), true);
//TODO: fix this condition
$useProps = true;
$iblockPropList = array();
$entityList = Sale\Internals\DiscountEntitiesTable::getByDiscount($arIDS, array('=MODULE_ID' => 'catalog', '=ENTITY' => 'ELEMENT_PROPERTY'));
if (empty($entityList)) {
$useProps = false;
} else {
if (empty($entityList['catalog']['ELEMENT_PROPERTY'])) {
$useProps = false;
} else {
foreach ($entityList['catalog']['ELEMENT_PROPERTY'] as $entity) {
$entityField = explode(':', $entity['FIELD_TABLE']);
if (isset($entityField[1])) {
$propId = (int) $entityField[1];
if ($propId > 0) {
$iblockPropList[$propId] = $propId;
}
unset($propId);
}
unset($entityField);
}
unset($entity);
if (empty($iblockPropList)) {
$useProps = false;
}
}
}
$arExtend = array('catalog' => array('fields' => true, 'props' => $useProps));
if ($useProps) {
$arExtend['iblock']['props'] = $iblockPropList;
}
unset($iblockPropList, $useProps);
//.........这里部分代码省略.........
示例3: GetList
function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
if (!is_array($arOrder) && !is_array($arFilter)) {
$arOrder = strval($arOrder);
$arFilter = strval($arFilter);
if (strlen($arOrder) > 0 && strlen($arFilter) > 0) {
$arOrder = array($arOrder => $arFilter);
} else {
$arOrder = array();
}
if (is_array($arGroupBy)) {
$arFilter = $arGroupBy;
} else {
$arFilter = array();
}
$arGroupBy = false;
$arSelectFields = array();
}
if (!$arSelectFields) {
$arSelectFields = array("ID", "PERSON_TYPE_ID", "NAME", "TYPE", "REQUIED", "DEFAULT_VALUE", "DEFAULT_VALUE_ORIG", "SORT", "USER_PROPS", "IS_LOCATION", "PROPS_GROUP_ID", "SIZE1", "SIZE2", "DESCRIPTION", "IS_EMAIL", "IS_PROFILE_NAME", "IS_PAYER", "IS_LOCATION4TAX", "IS_ZIP", "CODE", "IS_FILTERED", "ACTIVE", "UTIL", "INPUT_FIELD_LOCATION", "MULTIPLE", "PAYSYSTEM_ID", "DELIVERY_ID");
}
// add aliases
$query = new \Bitrix\Sale\Compatible\OrderQueryLocation(OrderPropsTable::getEntity());
$query->addLocationRuntimeField('DEFAULT_VALUE');
$query->addAliases(array('REQUIED' => 'REQUIRED', 'GROUP_ID' => 'GROUP.ID', 'GROUP_PERSON_TYPE_ID' => 'GROUP.PERSON_TYPE_ID', 'GROUP_NAME' => 'GROUP.NAME', 'GROUP_SORT' => 'GROUP.SORT', 'PERSON_TYPE_LID' => 'PERSON_TYPE.LID', 'PERSON_TYPE_NAME' => 'PERSON_TYPE.NAME', 'PERSON_TYPE_SORT' => 'PERSON_TYPE.SORT', 'PERSON_TYPE_ACTIVE' => 'PERSON_TYPE.ACTIVE', 'PAYSYSTEM_ID' => 'Bitrix\\Sale\\Internals\\OrderPropsRelationTable:lPROPERTY.PROPERTY_ID', 'DELIVERY_ID' => 'Bitrix\\Sale\\Internals\\OrderPropsRelationTable:lPROPERTY.PROPERTY_ID'));
// relations
if (isset($arFilter['RELATED'])) {
// 1. filter related to something
if (is_array($arFilter['RELATED'])) {
$relationFilter = array();
if ($arFilter['RELATED']['PAYSYSTEM_ID']) {
$relationFilter[] = array('=Bitrix\\Sale\\Internals\\OrderPropsRelationTable:lPROPERTY.ENTITY_TYPE' => 'P', '=Bitrix\\Sale\\Internals\\OrderPropsRelationTable:lPROPERTY.ENTITY_ID' => $arFilter['RELATED']['PAYSYSTEM_ID']);
}
if ($arFilter['RELATED']['DELIVERY_ID']) {
if ($relationFilter) {
$relationFilter['LOGIC'] = $arFilter['RELATED']['LOGIC'] == 'AND' ? 'AND' : 'OR';
}
$relationFilter[] = array('=Bitrix\\Sale\\Internals\\OrderPropsRelationTable:lPROPERTY.ENTITY_TYPE' => 'D', '=Bitrix\\Sale\\Internals\\OrderPropsRelationTable:lPROPERTY.ENTITY_ID' => \CSaleDelivery::getIdByCode($arFilter['RELATED']['DELIVERY_ID']));
}
// all other
if ($arFilter['RELATED']['TYPE'] == 'WITH_NOT_RELATED' && $relationFilter) {
$relationFilter = array('LOGIC' => 'OR', $relationFilter, array('=Bitrix\\Sale\\Internals\\OrderPropsRelationTable:lPROPERTY.PROPERTY_ID' => null));
}
if ($relationFilter) {
$query->addFilter(null, $relationFilter);
}
} else {
$query->addFilter('=Bitrix\\Sale\\Internals\\OrderPropsRelationTable:lPROPERTY.PROPERTY_ID', null);
if (($key = array_search('PAYSYSTEM_ID', $arSelectFields)) !== false) {
unset($arSelectFields[$key]);
}
if (($key = array_search('DELIVERY_ID', $arSelectFields)) !== false) {
unset($arSelectFields[$key]);
}
}
unset($arFilter['RELATED']);
}
if (isset($arFilter['PERSON_TYPE_ID']) && is_array($arFilter['PERSON_TYPE_ID'])) {
foreach ($arFilter['PERSON_TYPE_ID'] as $personTypeKey => $personTypeValue) {
if (!is_array($personTypeValue) && !empty($personTypeValue) && intval($personTypeValue) > 0) {
unset($arFilter['PERSON_TYPE_ID'][$personTypeKey]);
$arFilter['PERSON_TYPE_ID'][] = $personTypeValue;
}
}
}
// execute
$query->prepare($arOrder, $arFilter, $arGroupBy, $arSelectFields);
if ($query->counted()) {
return $query->exec()->getSelectedRowsCount();
} else {
$result = new \Bitrix\Sale\Compatible\CDBResult();
$adapter = new CSaleOrderPropsAdapter($query, $arSelectFields);
$adapter->addFieldProxy('DEFAULT_VALUE');
$result->addFetchAdapter($adapter);
return $query->compatibleExec($result, $arNavStartParams);
}
}
示例4: convertToNew
/**
* @return \Bitrix\Sale\Result
* @throws Exception
* @throws \Bitrix\Main\SystemException
*/
public static function convertToNew($renameTable = false)
{
$result = new \Bitrix\Sale\Result();
$con = \Bitrix\Main\Application::getConnection();
if (!$con->isTableExists("b_sale_delivery_handler")) {
return $result;
}
$sqlHelper = $con->getSqlHelper();
$deliveryRes = $con->query('SELECT * FROM b_sale_delivery_handler WHERE CONVERTED != \'Y\'');
$tablesToUpdate = array('b_sale_order', 'b_sale_order_history');
\CSaleDeliveryHandler::Initialize();
$handlers = \CSaleDeliveryHandler::__getRegisteredHandlers();
while ($delivery = $deliveryRes->fetch()) {
if (strlen($delivery["HID"]) <= 0) {
$result->addError(new \Bitrix\Main\Entity\EntityError("Can't find delivery HID. ID: \"" . $delivery["ID"] . "\""));
continue;
}
if (!isset($handlers[$delivery["HID"]])) {
\CEventLog::Add(array("SEVERITY" => "ERROR", "AUDIT_TYPE_ID" => "SALE_CONVERTER_ERROR", "MODULE_ID" => "sale", "ITEM_ID" => "CAllSaleDeliveryHandler::convertToNew()", "DESCRIPTION" => "Can't find delivery handler for registered HID: \"" . $delivery["HID"] . "\""));
//$result->addError( new \Bitrix\Main\Entity\EntityError("Can't find delivery handler for registered HID: \"".$delivery["HID"]."\""));
continue;
}
if (strlen($delivery["PROFILES"]) > 0) {
//get from base
$delivery["PROFILES"] = unserialize($delivery["PROFILES"]);
} else {
//or default.
$delivery["PROFILES"] = $handlers[$delivery["HID"]]["PROFILES"];
}
// Something strange it probably not used
if ($delivery["PROFILES"] == false || !is_array($delivery["PROFILES"]) || empty($delivery["PROFILES"])) {
$result->addError(new \Bitrix\Main\Entity\EntityError("Can't receive info about profiles. Delivery HID: \"" . $delivery["HID"] . "\""));
continue;
}
//Set profiles activity
foreach ($delivery["PROFILES"] as $id => $params) {
if (!isset($delivery["PROFILES"][$id]["ACTIVE"]) || $delivery["ACTIVE"] == "N") {
$delivery["PROFILES"][$id]["ACTIVE"] = $delivery["ACTIVE"];
}
}
unset($delivery["ID"]);
$delivery["CONFIG"] = array();
if (strlen($delivery["SETTINGS"]) > 0) {
if (isset($handlers[$delivery["HID"]]["DBGETSETTINGS"]) && is_callable($handlers[$delivery["HID"]]["DBGETSETTINGS"])) {
$delivery["CONFIG"] = call_user_func($handlers[$delivery["HID"]]["DBGETSETTINGS"], $delivery["SETTINGS"]);
} else {
$delivery["CONFIG"] = $delivery["SETTINGS"];
}
} elseif (isset($handlers[$delivery["HID"]]["GETCONFIG"]) && is_callable($handlers[$delivery["HID"]]["GETCONFIG"])) {
$config = call_user_func($handlers[$delivery["HID"]]["GETCONFIG"], strlen($delivery["LID"]) > 0 ? $delivery["LID"] : false);
foreach ($config["CONFIG"] as $key => $arConfig) {
if (!empty($arConfig["DEFAULT"])) {
$delivery["CONFIG"][$key] = $arConfig["DEFAULT"];
}
}
}
if (empty($delivery["NAME"])) {
if (!empty($handlers[$delivery["HID"]]["NAME"])) {
$delivery["NAME"] = $handlers[$delivery["HID"]]["NAME"];
} else {
$delivery["NAME"] = "-";
}
}
$delivery["SID"] = $handlers[$delivery["HID"]]["SID"];
$id = \CSaleDeliveryHandler::Set($delivery["HID"], $delivery, strlen($delivery["LID"]) > 0 ? $delivery["LID"] : false);
if (intval($id) <= 0) {
$result->addError(new \Bitrix\Main\Entity\EntityError("Can't convert delivery handler with hid: " . $delivery["HID"] . (strlen($delivery["LID"]) > 0 ? " for site: " . $delivery["LID"] : "")));
continue;
}
$con->queryExecute("UPDATE b_sale_delivery_handler SET CONVERTED='Y' WHERE HID LIKE '" . $sqlHelper->forSql($delivery["HID"]) . "'");
$ids = array($id);
foreach ($delivery["PROFILES"] as $profileName => $profileData) {
$fullSid = $delivery["HID"] . ":" . $profileName;
$profileId = \CSaleDelivery::getIdByCode($fullSid);
$ids[] = $profileId;
if (intval($profileId) > 0) {
foreach ($tablesToUpdate as $table) {
$con->queryExecute("UPDATE " . $table . " SET DELIVERY_ID='" . $sqlHelper->forSql($profileId) . "' WHERE DELIVERY_ID = '" . $sqlHelper->forSql($fullSid) . "'");
}
$con->queryExecute("UPDATE b_sale_delivery2paysystem SET DELIVERY_ID='" . $sqlHelper->forSql($profileId) . "', DELIVERY_PROFILE_ID='##CONVERTED##' WHERE DELIVERY_ID = '" . $sqlHelper->forSql($delivery["HID"]) . "' AND DELIVERY_PROFILE_ID='" . $profileName . "'");
} else {
$result->addError(new \Bitrix\Main\Entity\EntityError("Cant determine id for profile code: " . $fullSid));
}
}
$con->queryExecute("UPDATE b_sale_delivery2paysystem SET DELIVERY_ID='" . $sqlHelper->forSql($id) . "', DELIVERY_PROFILE_ID='##CONVERTED##' WHERE DELIVERY_ID = '" . $sqlHelper->forSql($delivery["HID"]) . "' AND (DELIVERY_PROFILE_ID='' OR DELIVERY_PROFILE_ID IS NULL)");
$d2pRes = \Bitrix\Sale\Internals\DeliveryPaySystemTable::getList(array('filter' => array('DELIVERY_ID' => $ids), 'select' => array("DELIVERY_ID"), 'group' => array("DELIVERY_ID")));
while ($d2p = $d2pRes->fetch()) {
$res = \Bitrix\Sale\Internals\ServiceRestrictionTable::add(array("SERVICE_ID" => $d2p["DELIVERY_ID"], "SERVICE_TYPE" => \Bitrix\Sale\Services\Base\RestrictionManager::SERVICE_TYPE_SHIPMENT, "CLASS_NAME" => '\\Bitrix\\Sale\\Delivery\\Restrictions\\ByPaySystem', "SORT" => 100));
if (!$res->isSuccess()) {
$result->addErrors($res->getErrors());
}
}
}
if ($renameTable && $result->isSuccess()) {
$con->renameTable('b_sale_delivery_handler', 'b_sale_delivery_handler_old');
//.........这里部分代码省略.........
示例5: Add
public static function Add($arFields)
{
if (!isset($arFields["DELIVERY_ID"]) || strlen(trim($arFields["DELIVERY_ID"])) <= 0 || !isset($arFields["PAYSYSTEM_ID"]) || intval($arFields["PAYSYSTEM_ID"]) <= 0) {
return false;
}
if (isset($arFields["DELIVERY_PROFILE_ID"]) && strlen($arFields["DELIVERY_PROFILE_ID"]) > 0) {
$arFields["DELIVERY_ID"] .= ":" . $arFields["DELIVERY_PROFILE_ID"];
unset($arFields["DELIVERY_PROFILE_ID"]);
}
$arFields["DELIVERY_ID"] = \CSaleDelivery::getIdByCode($arFields["DELIVERY_ID"]);
$res = DeliveryPaySystemTable::add($arFields);
return new CDBResult($res);
}
示例6: Delete
/**
* @deprecated
*/
public static function Delete($ID)
{
$newId = \CSaleDelivery::getIdByCode($ID);
try {
$res = \Bitrix\Sale\Delivery\Services\Manager::delete($newId);
} catch (\Bitrix\Main\SystemException $e) {
$GLOBALS["APPLICATION"]->ThrowException($e->getMessage());
return false;
}
return new CDBResult($res);
}