本文整理匯總了PHP中Bitrix\Sale\Order::setPersonTypeId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Order::setPersonTypeId方法的具體用法?PHP Order::setPersonTypeId怎麽用?PHP Order::setPersonTypeId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Bitrix\Sale\Order
的用法示例。
在下文中一共展示了Order::setPersonTypeId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: fillSimpleFields
/**
* @param Order $order
* @param array $formData
* @param int $userId
*
* @return \Bitrix\Sale\Result
*/
protected static function fillSimpleFields(Order $order, array $formData, $userId = 0)
{
$result = new \Bitrix\Sale\Result();
if (isset($formData["ORDER"]["RESPONSIBLE_ID"])) {
/** @var \Bitrix\Sale\Result $r */
$r = $order->setField("RESPONSIBLE_ID", $formData["ORDER"]["RESPONSIBLE_ID"]);
if (!$r->isSuccess()) {
$result->addErrors($r->getErrors());
}
}
if (isset($formData["PERSON_TYPE_ID"]) && intval($formData["PERSON_TYPE_ID"]) > 0) {
/** @var \Bitrix\Sale\Result $r */
$r = $order->setPersonTypeId(intval($formData['PERSON_TYPE_ID']));
} else {
/** @var \Bitrix\Sale\Result $r */
$r = $order->setPersonTypeId(Blocks\OrderBuyer::getDefaultPersonType($order->getSiteId()));
}
if (!$r->isSuccess()) {
$result->addErrors($r->getErrors());
}
if (isset($formData["ORDER"]["COMMENTS"])) {
/** @var \Bitrix\Sale\Result $r */
$r = $order->setField("COMMENTS", $formData["ORDER"]["COMMENTS"]);
if (!$r->isSuccess()) {
$result->addErrors($r->getErrors());
}
}
if (isset($formData["USER_DESCRIPTION"])) {
/** @var \Bitrix\Sale\Result $r */
$r = $order->setField("USER_DESCRIPTION", $formData["USER_DESCRIPTION"]);
if (!$r->isSuccess()) {
$result->addErrors($r->getErrors());
}
}
if (isset($formData["RESPONSIBLE_ID"])) {
/** @var \Bitrix\Sale\Result $r */
$r = $order->setField("RESPONSIBLE_ID", $formData["RESPONSIBLE_ID"]);
if (!$r->isSuccess()) {
$result->addErrors($r->getErrors());
}
}
if (isset($formData["STATUS_ID"]) && strlen($formData["STATUS_ID"]) > 0) {
$statusesList = \Bitrix\Sale\OrderStatus::getAllowedUserStatuses($userId, \Bitrix\Sale\OrderStatus::getInitialStatus());
if (array_key_exists($formData["STATUS_ID"], $statusesList)) {
/** @var \Bitrix\Sale\Result $r */
$r = $order->setField("STATUS_ID", $formData["STATUS_ID"]);
if (!$r->isSuccess()) {
$result->addErrors($r->getErrors());
}
}
}
return $result;
}
示例2: fillSimpleFields
/**
* @param Order $order
* @param array $formData
* @param int $userId
* @return Order
* @throws \Bitrix\Main\ArgumentOutOfRangeException
*/
protected static function fillSimpleFields(Order $order, array $formData, $userId = 0)
{
if (isset($formData["ORDER"]["RESPONSIBLE_ID"])) {
$order->setField("RESPONSIBLE_ID", $formData["ORDER"]["RESPONSIBLE_ID"]);
}
if (isset($formData["PERSON_TYPE_ID"]) && $formData["PERSON_TYPE_ID"] > 0) {
$order->setPersonTypeId($formData['PERSON_TYPE_ID']);
}
if (isset($formData["ORDER"]["COMMENTS"])) {
$order->setField("COMMENTS", $formData["ORDER"]["COMMENTS"]);
}
if (isset($formData["USER_DESCRIPTION"])) {
$order->setField("USER_DESCRIPTION", $formData["USER_DESCRIPTION"]);
}
if (isset($formData["RESPONSIBLE_ID"])) {
$order->setField("RESPONSIBLE_ID", $formData["RESPONSIBLE_ID"]);
}
if (isset($formData["STATUS_ID"]) && strlen($formData["STATUS_ID"]) > 0) {
$statusesList = \Bitrix\Sale\OrderStatus::getAllowedUserStatuses($userId, \Bitrix\Sale\OrderStatus::getInitialStatus());
if (array_key_exists($formData["STATUS_ID"], $statusesList)) {
$order->setField("STATUS_ID", $formData["STATUS_ID"]);
}
}
return $order;
}