本文整理汇总了PHP中CSaleOrder::SetMark方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleOrder::SetMark方法的具体用法?PHP CSaleOrder::SetMark怎么用?PHP CSaleOrder::SetMark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleOrder
的用法示例。
在下文中一共展示了CSaleOrder::SetMark方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ReserveOrder
function ReserveOrder($ID, $val, $recurringID = 0)
{
global $DB, $USER;
$ID = IntVal($ID);
$val = $val != "Y" ? "N" : "Y";
$recurringID = IntVal($recurringID);
if ($ID <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_NO_ORDER_ID"), "NO_ORDER_ID");
return false;
}
$arOrder = CSaleOrder::GetByID($ID);
if (!$arOrder) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGO_NO_ORDER")), "NO_ORDER");
return false;
//TODO - UnsetMark?
}
if ($arOrder["RESERVED"] == $val) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGO_DUB_RESERVATION")), "ALREADY_FLAG");
return false;
}
foreach (GetModuleEvents("sale", "OnSaleBeforeReserveOrder", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID, $val, $recurringID, $arAdditionalFields)) === false) {
return false;
}
}
unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_" . $ID]);
if ($recurringID <= 0) {
if (IntVal($arOrder["RECURRING_ID"]) > 0) {
$recurringID = IntVal($arOrder["RECURRING_ID"]);
}
}
//TODO - recurring?
$res = CSaleOrder::Update($ID, array("RESERVED" => $val));
$arRes = CSaleBasket::OrderReservation($ID, $val == "N" ? true : false, $recurringID);
if (array_key_exists("ERROR", $arRes)) {
foreach ($arRes["ERROR"] as $productId => $arError) {
$errorMessage .= " " . $arError["MESSAGE"];
}
CSaleOrder::SetMark($ID, GetMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $errorMessage)));
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $errorMessage)), "RESERVATION_ERROR");
return false;
} else {
//don't unset if not set yet
CSaleOrder::UnsetMark($ID);
}
foreach (GetModuleEvents("sale", "OnSaleReserveOrder", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $val));
}
return $res;
}
示例2: trim
if (strlen($errorMessageTmp) <= 0)
{
$MARKED = trim($_REQUEST["MARKED"]);
$REASON_MARKED = trim($_REQUEST["REASON_MARKED"]);
if ($MARKED != "Y")
$MARKED = "N";
if ($MARKED != "Y" && $MARKED != "N")
$errorMessageTmp .= GetMessage("SOD_WRONG_MARK_FLAG").". ";
}
if (strlen($errorMessageTmp) <= 0 && !CSaleOrder::IsLocked($ID, $lockedBY, $dateLock))
{
if ($MARKED == "Y")
$rs = CSaleOrder::SetMark($ID, $REASON_MARKED, (0 < $intUserID ? $intUserID : 0));
else
$rs = CSaleOrder::UnsetMark($ID, (0 < $intUserID ? $intUserID : 0));
if (!$rs)
{
if ($ex = $APPLICATION->GetException())
{
if ($ex->GetID() != "ALREADY_FLAG")
$errorMessageTmp .= $ex->GetString();
}
else
$errorMessageTmp .= GetMessage("ERROR_MARK_ORDER").". ";
}
}
示例3: GetMessage
$MARKED = "N";
if (($arOldOrder["MARKED"] != $MARKED) || ($arOldOrder["MARKED"] == "Y" && $arOldOrder["REASON_MARKED"] != $REASON_MARKED))
{
$bUserCanMarkOrder = CSaleOrder::CanUserMarkOrder($ID, $arUserGroups, $intUserID);
$errorMessageTmp = "";
if (!$bUserCanMarkOrder)
{
$errorMessageTmp .= GetMessage("SOD_NO_PERMS2MARK").". ";
}
else
{
if ($MARKED == "Y")
$rs = CSaleOrder::SetMark($ID, $REASON_MARKED, $intUserID);
else
$rs = CSaleOrder::UnsetMark($ID, $intUserID);
if (!$rs)
{
if ($ex = $APPLICATION->GetException())
{
if ($ex->GetID() != "ALREADY_FLAG")
$errorMessageTmp .= $ex->GetString();
}
else
$errorMessageTmp .= GetMessage("ERROR_MARK_ORDER").". ";
}
}
示例4: DoChangeProductQuantity
/**
* Changes product quantity in the catalog.
* Used in the DoSaveOrderBasket to actualize basket items quantity
* after some operations with the order are made in the order_new form
*
* Depending on the state of the order (reserved/deducted)
* and the state of the product (reserved/deducted) calls appropriate provider methods
*
* If the quantity is 0 and CHECK_QUANTITY is N, this method is used only to call OrderProduct method to actualize coupon data
*
* @param array $arBasketItem - basket item data array
* @param int $deltaQuantity - quantity to be changed. Can be zero, in this case CHECK_QUANTITY should be N
* @param bool $isOrderReserved - order reservation flag
* @param bool $isOrderDeducted - order deduction flag
* @param array $arStoreBarcodeOrderFormData - array of barcode and stores from order_new form to be used for deduction
* @param array $arAdditionalParams - user id, site id, check_quantity flag
* @return bool
*/
public static function DoChangeProductQuantity($arBasketItem, $deltaQuantity, $isOrderReserved = false, $isOrderDeducted = false, $arStoreBarcodeOrderFormData = array(), $arAdditionalParams = array())
{
global $APPLICATION;
if (!array_key_exists("CHECK_QUANTITY", $arAdditionalParams) || $arAdditionalParams["CHECK_QUANTITY"] != "N") {
$arAdditionalParams["CHECK_QUANTITY"] = "Y";
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("DoChangeProductQuantity - Started", array("arBasketItem" => $arBasketItem, "deltaQuantity" => $deltaQuantity, "isOrderReserved" => intval($isOrderReserved), "isOrderDeducted" => intval($isOrderDeducted), "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData, "checkQuantity" => $arAdditionalParams["CHECK_QUANTITY"]), "DCPQ1");
}
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasketItem)) {
$productProvider::OrderProduct(array("PRODUCT_ID" => $arBasketItem["PRODUCT_ID"], "QUANTITY" => $deltaQuantity <= 0 ? $arBasketItem['QUANTITY'] : $deltaQuantity, "RENEWAL" => "N", "USER_ID" => $arAdditionalParams["USER_ID"], "SITE_ID" => $arAdditionalParams["SITE_ID"], "CHECK_QUANTITY" => $arAdditionalParams["CHECK_QUANTITY"], "BASKET_ID" => $arBasketItem['ID']));
if ($deltaQuantity == 0 && $arAdditionalParams["CHECK_QUANTITY"] == 'N') {
return true;
}
if ($isOrderDeducted) {
$quantityPreviouslyLeftToReserve = $arBasketItem["RESERVED"] == "Y" ? floatval($arBasketItem["RESERVE_QUANTITY"]) : 0;
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity, "quantityPreviouslyLeftToReserve" => $quantityPreviouslyLeftToReserve, "isOrderDeducted" => $isOrderDeducted), "DCPQ2");
}
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity + $quantityPreviouslyLeftToReserve, $isOrderDeducted);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], Loc::getMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::DeductBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity, "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData), "DCPQ3");
}
$arDeductResult = CSaleBasket::DeductBasketProduct($arBasketItem["ID"], $deltaQuantity, $arStoreBarcodeOrderFormData);
if (array_key_exists("ERROR", $arDeductResult)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], Loc::getMessage("SKGB_DEDUCT_ERROR", array("#MESSAGE#" => $arDeductResult["ERROR"]["MESSAGE"])));
$APPLICATION->ThrowException(Loc::getMessage("SKGB_DEDUCT_ERROR", array("#MESSAGE#" => $arDeductResult["ERROR"]["MESSAGE"])), "DEDUCTION_ERROR");
return false;
}
} else {
if ($isOrderReserved && !$isOrderDeducted) {
if ($arBasketItem["RESERVED"] == "Y") {
$quantityPreviouslyLeftToReserve = floatval($arBasketItem["RESERVE_QUANTITY"]);
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity, "quantityPreviouslyLeftToReserve" => $quantityPreviouslyLeftToReserve), "DCPQ4");
}
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity + $quantityPreviouslyLeftToReserve);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], Loc::getMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
} else {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity), "DCPQ5");
}
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], Loc::getMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
}
} else {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity), "DCPQ6");
}
if ($arBasketItem["RESERVED"] == "Y") {
$quantityPreviouslyLeftToReserve = floatval($arBasketItem["RESERVE_QUANTITY"]);
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity + $quantityPreviouslyLeftToReserve);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], Loc::getMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
}
}
}
} else {
if ($deltaQuantity < 0) {
CSaleBasket::ExecuteCallbackFunction($arBasketItem["CANCEL_CALLBACK_FUNC"], $arBasketItem["MODULE"], $arBasketItem["PRODUCT_ID"], abs($deltaQuantity), true);
} else {
if ($deltaQuantity > 0) {
CSaleBasket::ExecuteCallbackFunction($arBasketItem["ORDER_CALLBACK_FUNC"], $arBasketItem["MODULE"], $arBasketItem["PRODUCT_ID"], $deltaQuantity, "N", $arAdditionalParams["USER_ID"], $arAdditionalParams["SITE_ID"]);
} else {
if ($deltaQuantity == 0) {
CSaleBasket::ExecuteCallbackFunction($arBasketItem["ORDER_CALLBACK_FUNC"], $arBasketItem["MODULE"], $arBasketItem["PRODUCT_ID"], $arBasketItem['QUANTITY'], "N", $arAdditionalParams["USER_ID"], $arAdditionalParams["SITE_ID"]);
}
}
}
//.........这里部分代码省略.........
示例5: ReserveOrder
function ReserveOrder($ID, $val)
{
global $APPLICATION;
$ID = IntVal($ID);
$val = $val != "Y" ? "N" : "Y";
$errorMessage = "";
$isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
if ($ID <= 0) {
$APPLICATION->ThrowException(Loc::getMessage("SKGO_NO_ORDER_ID"), "NO_ORDER_ID");
return false;
}
$arOrder = CSaleOrder::GetByID($ID);
if (!$arOrder) {
$APPLICATION->ThrowException(str_replace("#ID#", $ID, Loc::getMessage("SKGO_NO_ORDER")), "NO_ORDER");
return false;
}
if ($arOrder["RESERVED"] == $val) {
$APPLICATION->ThrowException(str_replace("#ID#", $ID, Loc::getMessage("SKGO_DUB_RESERVATION")), "ALREADY_FLAG");
return false;
}
foreach (GetModuleEvents("sale", "OnSaleBeforeReserveOrder", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID, $val)) === false) {
return false;
}
}
unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_" . $ID]);
if ($isOrderConverted == "Y") {
/** @var \Bitrix\Sale\Result $r */
$r = \Bitrix\Sale\Compatible\OrderCompatibility::reserve($ID, $val);
if (!$r->isSuccess(true)) {
foreach ($r->getErrorMessages() as $error) {
$errorMessage .= " " . $error;
}
$APPLICATION->ThrowException(Loc::getMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $errorMessage)), "RESERVATION_ERROR");
return false;
}
$res = true;
} else {
$res = CSaleOrder::Update($ID, array("RESERVED" => $val), false);
$arRes = CSaleBasket::OrderReservation($ID, $val == "N" ? true : false);
if (array_key_exists("ERROR", $arRes)) {
foreach ($arRes["ERROR"] as $arError) {
$errorMessage .= " " . $arError["MESSAGE"];
}
CSaleOrder::SetMark($ID, Loc::getMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $errorMessage)));
$APPLICATION->ThrowException(Loc::getMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $errorMessage)), "RESERVATION_ERROR");
return false;
} else {
if ($arOrder["MARKED"] == "Y") {
CSaleOrder::UnsetMark($ID);
}
}
}
foreach (GetModuleEvents("sale", "OnSaleReserveOrder", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $val));
}
return $res;
}
示例6: ClearProductReservedQuantity
/**
* The agent function. Moves reserved quantity back to the quantity field for each product
* for orders which were placed earlier than specific date
*
* @return agent name string
*/
public static function ClearProductReservedQuantity()
{
global $DB, $USER;
if (!is_object($USER))
$USER = new CUser;
$days_ago = COption::GetOptionString("sale", "product_reserve_clear_period", "0");
if (intval($days_ago) > 0)
{
$date = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), time() - intval($days_ago)*24*60*60);
$arFilter = array(
"<=DATE_INSERT" => $date,
"RESERVED" => "Y",
"DEDUCTED" => "N",
"PAYED" => "N",
"ALLOW_DELIVERY" => "N",
"CANCELED" => "N"
);
$dbRes = CSaleOrder::GetList(
array(),
$arFilter,
false,
false,
array("ID", "RESERVED", "DATE_INSERT", "DEDUCTED", "PAYED", "CANCELED", "MARKED")
);
while ($arRes = $dbRes->GetNext())
{
foreach(GetModuleEvents("sale", "OnSaleBeforeReserveOrder", true) as $arEvent)
if (ExecuteModuleEventEx($arEvent, array($arRes["ID"], "N", $arAdditionalFields))===false)
return false;
// undoing reservation
$res = CSaleBasket::OrderReservation($arRes["ID"], true);
if (array_key_exists("ERROR", $res))
{
foreach ($res["ERROR"] as $productId => $arError)
$errorMessage .= " ".$arError["MESSAGE"];
CSaleOrder::SetMark($arRes["ID"], GetMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $errorMessage)));
}
else
{
if ($arOrder["MARKED"] == "Y")
CSaleOrder::UnsetMark($arRes["ID"]);
}
$res = CSaleOrder::Update($arRes["ID"], array("RESERVED" => "N"), false);
foreach(GetModuleEvents("sale", "OnSaleReserveOrder", true) as $arEvent)
ExecuteModuleEventEx($arEvent, Array($arRes["ID"], "N"));
}
}
return "CSaleOrder::ClearProductReservedQuantity();";
}
示例7: trim
if ($ID > 0 and count($arErrors) <= 0) {
$MARKED = trim($_POST["MARKED"]);
$REASON_MARKED = trim($_POST["REASON_MARKED"]);
if ($MARKED != "Y") {
$MARKED = "N";
}
$arOrder2Update = array();
if ($arOldOrder["MARKED"] != $MARKED || $arOldOrder["MARKED"] == "Y" && $arOldOrder["REASON_MARKED"] != $REASON_MARKED) {
$bUserCanMarkOrder = CSaleOrder::CanUserMarkOrder($ID, $GLOBALS["USER"]->GetUserGroupArray(), $GLOBALS["USER"]->GetID());
$errorMessageTmp = "";
if (!$bUserCanMarkOrder) {
$errorMessageTmp .= GetMessage("SOD_NO_PERMS2MARK") . ". ";
}
if (strlen($errorMessageTmp) <= 0) {
if ($MARKED == "Y") {
$rs = CSaleOrder::SetMark($ID, $REASON_MARKED, intval($GLOBALS["USER"]->GetID()) > 0 ? IntVal($GLOBALS["USER"]->GetID()) : 0);
} else {
$rs = CSaleOrder::UnsetMark($ID, intval($GLOBALS["USER"]->GetID()) > 0 ? IntVal($GLOBALS["USER"]->GetID()) : 0);
}
if (!$rs) {
if ($ex = $APPLICATION->GetException()) {
if ($ex->GetID() != "ALREADY_FLAG") {
$errorMessageTmp .= $ex->GetString();
}
} else {
$errorMessageTmp .= GetMessage("ERROR_MARK_ORDER") . ". ";
}
}
}
if ($errorMessageTmp != "") {
$arErrors[] = $errorMessageTmp;
示例8: SetStatus
public function SetStatus($ID, $statusID, $statusParams = false, $options = array())
{
global $USER;
if (!CModule::IncludeModule('sale')) {
return false;
}
$currentUserId = 0;
if (isset($USER) && (get_class($USER) === 'CUser' || $USER instanceof CUser)) {
$currentUserId = $USER->GetID();
}
$result = true;
if (!self::$INVOICE_STATUSES) {
self::$INVOICE_STATUSES = CCrmStatus::GetStatus('INVOICE_STATUS');
}
if (!is_array(self::$INVOICE_STATUSES) || count(self::$INVOICE_STATUSES) <= 2 || !array_key_exists('P', self::$INVOICE_STATUSES) || !array_key_exists('D', self::$INVOICE_STATUSES) || self::$INVOICE_STATUSES['P']['SORT'] >= self::$INVOICE_STATUSES['D']['SORT']) {
$result = false;
}
if ($result) {
$CSaleOrder = new CSaleOrder();
// get current state
if (!($arOrder = CSaleOrder::GetByID($ID))) {
$result = false;
}
if ($result) {
$curPay = $arOrder['PAYED'];
$curCancel = $arOrder['CANCELED'];
$curMarked = $arOrder['MARKED'];
$curStatusID = $arOrder['STATUS_ID'];
$pay = $cancel = 'N';
$marked = isset($statusParams['REASON_MARKED']) || isset($statusParams['DATE_MARKED']) ? 'Y' : 'N';
if (self::$INVOICE_STATUSES[$statusID]['SORT'] >= self::$INVOICE_STATUSES['P']['SORT']) {
$pay = 'Y';
}
if (self::$INVOICE_STATUSES[$statusID]['SORT'] >= self::$INVOICE_STATUSES['D']['SORT']) {
$pay = 'N';
$cancel = 'Y';
}
if ($curPay != $pay) {
$result = $CSaleOrder->PayOrder($ID, $pay, true, true, 0, array('NOT_CHANGE_STATUS' => 'Y'));
}
if ($result && $curCancel != $cancel) {
$result = $CSaleOrder->CancelOrder($ID, $cancel);
}
if ($result && $marked === 'Y') {
$result = $CSaleOrder->SetMark($ID, isset($statusParams['REASON_MARKED']) ? $statusParams['REASON_MARKED'] : '', $currentUserId);
}
if ($result) {
$arUpdate = array();
if (isset($statusParams['DATE_MARKED'])) {
$arUpdate['DATE_MARKED'] = $statusParams['DATE_MARKED'];
}
if ($pay === 'Y') {
if (isset($statusParams['PAY_VOUCHER_NUM'])) {
$arUpdate['PAY_VOUCHER_NUM'] = $statusParams['PAY_VOUCHER_NUM'];
}
if (isset($statusParams['PAY_VOUCHER_DATE'])) {
$arUpdate['PAY_VOUCHER_DATE'] = $statusParams['PAY_VOUCHER_DATE'];
}
}
if (count($arUpdate) > 0) {
$result = self::Update($ID, $arUpdate);
}
unset($arUpdate);
}
if ($result && $curStatusID != $statusID) {
$result = $CSaleOrder->StatusOrder($ID, $statusID) === $ID;
}
}
}
if ($result && is_array($options) && isset($options['SYNCHRONIZE_LIVE_FEED']) && $options['SYNCHRONIZE_LIVE_FEED']) {
self::SynchronizeLiveFeedEvent($ID, array('PROCESS_PARENTS' => false, 'REFRESH_DATE' => true));
}
return $result;
}
示例9: DoChangeProductQuantity
public static function DoChangeProductQuantity($arBasketItem, $deltaQuantity, $isOrderReserved = false, $isOrderDeducted = false, $arStoreBarcodeOrderFormData = array(), $arAdditionalParams = array())
{
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("DoChangeProductQuantity - Started", array("arBasketItem" => $arBasketItem, "deltaQuantity" => $deltaQuantity, "isOrderReserved" => intval($isOrderReserved), "isOrderDeducted" => intval($isOrderDeducted), "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData), "DCPQ1");
}
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasketItem)) {
if ($isOrderReserved && $isOrderDeducted) {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::DeductBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity, "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData), "DCPQ2");
}
$arDeductResult = CSaleBasket::DeductBasketProduct($arBasketItem["ID"], $deltaQuantity, $arStoreBarcodeOrderFormData);
if (array_key_exists("ERROR", $arDeductResult)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], GetMessage("SKGB_DEDUCT_ERROR", array("#MESSAGE#" => $arDeductResult["ERROR"]["MESSAGE"])));
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGB_DEDUCT_ERROR", array("#MESSAGE#" => $arDeductResult["ERROR"]["MESSAGE"])), "DEDUCTION_ERROR");
return false;
}
} else {
if (!$isOrderReserved && $isOrderDeducted) {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::DeductBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity, "arStoreBarcodeOrderFormData" => $arStoreBarcodeOrderFormData), "DCPQ3");
}
$arDeductResult = CSaleBasket::DeductBasketProduct($arBasketItem["ID"], $deltaQuantity, $arStoreBarcodeOrderFormData);
if (array_key_exists("ERROR", $arDeductResult)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], GetMessage("SKGB_DEDUCT_ERROR", array("#MESSAGE#" => $arDeductResult["ERROR"]["MESSAGE"])));
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGB_DEDUCT_ERROR", array("#MESSAGE#" => $arDeductResult["ERROR"]["MESSAGE"])), "DEDUCTION_ERROR");
return false;
}
} else {
if ($isOrderReserved && !$isOrderDeducted) {
if ($arBasketItem["RESERVED"] == "Y") {
$quantityPreviouslyLeftToReserve = DoubleVal($arBasketItem["RESERVE_QUANTITY"]);
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity, "quantityPreviouslyLeftToReserve" => $quantityPreviouslyLeftToReserve), "DCPQ4");
}
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity + $quantityPreviouslyLeftToReserve);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], GetMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
} else {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity), "DCPQ5");
}
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], GetMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
}
} else {
if (defined("SALE_DEBUG") && SALE_DEBUG) {
CSaleHelper::WriteToLog("Call ::ReserveBasketProduct", array("arBasketItemID" => $arBasketItem["ID"], "deltaQuantity" => $deltaQuantity), "DCPQ6");
}
if ($arBasketItem["RESERVED"] == "Y") {
$quantityPreviouslyLeftToReserve = DoubleVal($arBasketItem["RESERVE_QUANTITY"]);
$arRes = CSaleBasket::ReserveBasketProduct($arBasketItem["ID"], $deltaQuantity + $quantityPreviouslyLeftToReserve);
if (array_key_exists("ERROR", $arRes)) {
CSaleOrder::SetMark($arAdditionalParams["ORDER_ID"], GetMessage("SKGB_RESERVE_ERROR", array("#MESSAGE#" => $arRes["ERROR"]["MESSAGE"])));
return false;
}
}
}
}
}
} else {
if ($deltaQuantity < 0) {
CSaleBasket::ExecuteCallbackFunction($arBasketItem["CANCEL_CALLBACK_FUNC"], $arBasketItem["MODULE"], $arBasketItem["PRODUCT_ID"], $deltaQuantity, true);
} else {
if ($deltaQuantity > 0) {
CSaleBasket::ExecuteCallbackFunction($arBasketItem["ORDER_CALLBACK_FUNC"], $arBasketItem["MODULE"], $arBasketItem["PRODUCT_ID"], $deltaQuantity, "N", $arAdditionalParams["USER_ID"], $arAdditionalParams["SITE_ID"]);
}
}
}
}
示例10: formAndSendDataToGP
//.........这里部分代码省略.........
}
}
}
// send data to GP server
if ($options["URL"]) {
$arConfig = self::$CONFIG;
$stop_send = false;
$ch = curl_init();
if (intVal($_POST[$post_key['gp_order_id']]) == 0) {
$type = "POST";
//$options["URL"] = COption::GetOptionString(self::$MODULE_ID, 'POST_url');
$options["URL"] = COption::GetOptionString(self::$MODULE_ID, 'gp_script_url') . $arConfig["POST_URL"];
}
if ($type == "POST" && !empty($post_data['widget_token'])) {
$post_data['with_draft'] = true;
}elseif($type == "POST" && empty($post_data['widget_token'])){
$post_data['with_draft'] = false;
}
// set data for sending to GP server
$send_data = json_encode($post_data);
if ($type == "POST") {
curl_setopt($ch, CURLOPT_POST, true);
} elseif ($type == "PATCH") {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
} else {
$stop_send = true;
}
curl_setopt($ch, CURLOPT_URL, $options["URL"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $send_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (!$stop_send) {
$result = json_decode(curl_exec($ch), true);
}
curl_close($ch);
if (is_array($result['error_message']) && count($result['error_message']) == 1) {
$comment = implode("\r\n", $result['error_message']);
$comment = CGPWidget::Translate($comment);
CSaleOrder::SetMark($ID, $comment);
} elseif (is_array($result['error_message']) && count($result['error_message']) > 1) {
$comment = $result['error_message'];
$ar_comment = "";
foreach($comment as $com){
$ar_comment .= CGPWidget::Translate($com).". ";
}
CSaleOrder::SetMark($ID, $ar_comment);
} elseif ($result) {
if ($order_is_marked) {
CSaleOrder::UnsetMark($ID);
}
if (intVal($_POST[$post_key['gp_order_id_0']]) == 0 && $result['id']/* && intVal($_POST[$post_key['gp_order_id']]) != $result['id']*/) {
// $_POST[$post_key['gp_order_id']] = $result['id'];
if ($gp_order_id_prop_id = intVal(str_replace("ORDER_PROP_", "", $post_key['gp_order_id_0']))) {
$gp_order_id_res = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $ID, "ORDER_PROPS_ID" => $gp_order_id_prop_id));
if ($gp_order_id_ar = $gp_order_id_res->Fetch()) {
$gp_order_id_prop_value_id = $gp_order_id_ar['ID'];
if ($gp_order_id_prop_value_id) {
$gp_order_id_add_result = CSaleOrderPropsValue::Update($gp_order_id_prop_value_id, array("ORDER_ID" => $ID, "VALUE" => $result['id']));
}
} else {
$gp_order_id_prop_res = CSaleOrderProps::GetList(array(), array("ID" => $gp_order_id_prop_id));
if ($gp_order_id_prop_ar = $gp_order_id_prop_res->Fetch()) {
$gp_order_id_add_result = CSaleOrderPropsValue::Add(array("ORDER_ID" => $ID, "ORDER_PROPS_ID" => $gp_order_id_prop_id, "VALUE" => $result['id'], "NAME" => $gp_order_id_prop_ar['NAME'], "CODE" => $gp_order_id_prop_ar['CODE']));
}
}
}
}
}
/*
echo "<pre>";
var_dump($_POST);
var_dump($post_data);
var_dump($result);
echo "</pre>";
die();*/
}
// log everything
$filename = $_SERVER['DOCUMENT_ROOT'] . '/templog.log';
$data = array($type, date('d.m.Y h:i:s'), "ORDER" => $ID, "URL" => $options["URL"], "SEND" => $send_data, "RESULT" => $result, "ARFIELDS" => $arFields);
// $data = array($type, date('d.m.Y h:i:s'), "ORDER" => $ID, "URL" => $options["URL"], "SEND" => $send_data, "gpid" => array('add' => $m, 'res' => $gp_order_id_add_result, '1' => array($gp_order_id_prop_value_id, array("ORDER_ID" => $ID, "VALUE" => $result['id'])), 'ar' => $gp_order_id_ar, 'val' => $gp_order_id_prop_value_id, 'post_gpoid' => $result['id'], "ORDER_ID" => $ID, 'ORDER_PROPS_ID' => str_replace("ORDER_PROP_", "", $post_key['gp_order_id'])), array($_POST[$post_key['gp_order_id']], $post_key['gp_order_id']), "RESULT" => $result);
// $data = array($type, date('d.m.Y h:i:s'), $ID, $send_data, $result, $city_name, $city_id, $post_key, $_POST);
file_put_contents($filename, var_export($data, true), FILE_APPEND | LOCK_EX);
}