本文整理汇总了PHP中CSaleOrder::ReserveOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleOrder::ReserveOrder方法的具体用法?PHP CSaleOrder::ReserveOrder怎么用?PHP CSaleOrder::ReserveOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleOrder
的用法示例。
在下文中一共展示了CSaleOrder::ReserveOrder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CancelOrder
function CancelOrder($ID, $val, $description = "")
{
global $DB, $USER;
$ID = IntVal($ID);
$val = $val != "Y" ? "N" : "Y";
$description = Trim($description);
if ($ID <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_NO_ORDER_ID1"), "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;
}
if ($arOrder["CANCELED"] == $val) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGO_DUB_CANCEL")), "ALREADY_FLAG");
return False;
}
foreach (GetModuleEvents("sale", "OnSaleBeforeCancelOrder", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID, $val)) === false) {
return false;
}
}
if ($val == "Y") {
if ($arOrder["PAYED"] == "Y") {
if (!CSaleOrder::PayOrder($ID, "N", True, True)) {
return False;
}
} else {
$arOrder["SUM_PAID"] = DoubleVal($arOrder["SUM_PAID"]);
if ($arOrder["SUM_PAID"] > 0) {
if (!CSaleUserAccount::UpdateAccount($arOrder["USER_ID"], $arOrder["SUM_PAID"], $arOrder["CURRENCY"], "ORDER_CANCEL_PART", $ID)) {
return False;
}
}
}
if ($arOrder["ALLOW_DELIVERY"] == "Y") {
if (!CSaleOrder::DeliverOrder($ID, "N")) {
return False;
}
}
}
$arFields = array("CANCELED" => $val, "=DATE_CANCELED" => $DB->GetNowFunction(), "REASON_CANCELED" => strlen($description) > 0 ? $description : false, "EMP_CANCELED_ID" => IntVal($USER->GetID()) > 0 ? IntVal($USER->GetID()) : false);
$res = CSaleOrder::Update($ID, $arFields);
unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_" . $ID]);
//this method is used only for catalogs without reservation and deduction support
CSaleBasket::OrderCanceled($ID, $val == "Y" ? True : False);
foreach (GetModuleEvents("sale", "OnSaleCancelOrder", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $val, $description));
}
if ($val == "Y") {
CTimeZone::Disable();
$arOrder = CSaleOrder::GetByID($ID);
CTimeZone::Enable();
$userEmail = "";
$dbOrderProp = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $ID, "PROP_IS_EMAIL" => "Y"));
if ($arOrderProp = $dbOrderProp->Fetch()) {
$userEmail = $arOrderProp["VALUE"];
}
if (strlen($userEmail) <= 0) {
$dbUser = CUser::GetByID($arOrder["USER_ID"]);
if ($arUser = $dbUser->Fetch()) {
$userEmail = $arUser["EMAIL"];
}
}
$event = new CEvent();
$arFields = array("ORDER_ID" => $ID, "ORDER_DATE" => $arOrder["DATE_INSERT_FORMAT"], "EMAIL" => $userEmail, "ORDER_CANCEL_DESCRIPTION" => $description, "SALE_EMAIL" => COption::GetOptionString("sale", "order_email", "order@" . $_SERVER["SERVER_NAME"]));
$eventName = "SALE_ORDER_CANCEL";
$bSend = true;
foreach (GetModuleEvents("sale", "OnOrderCancelSendEmail", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID, &$eventName, &$arFields)) === false) {
$bSend = false;
}
}
if ($bSend) {
$event = new CEvent();
$event->Send($eventName, $arOrder["LID"], $arFields, "N");
}
if (CModule::IncludeModule("statistic")) {
CStatEvent::AddByEvents("eStore", "order_cancel", $ID, "", $arOrder["STAT_GID"]);
}
}
if ($val == "Y") {
if ($arOrder["DEDUCTED"] == "Y") {
$rs = CSaleOrder::DeductOrder($ID, "N");
if (!$rs) {
return false;
}
}
if ($arOrder["RESERVED"] == "Y") {
if (!CSaleOrder::ReserveOrder($ID, "N")) {
}
return false;
}
} else {
if (COption::GetOptionString("sale", "product_reserve_condition", "O") == "O" && $arOrder["RESERVED"] != "Y") {
if (!CSaleOrder::ReserveOrder($ID, "Y")) {
}
return false;
//.........这里部分代码省略.........
示例2: CancelOrder
function CancelOrder($ID, $val, $description = "")
{
global $DB, $USER, $APPLICATION;
$isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
$ID = IntVal($ID);
$val = $val != "Y" ? "N" : "Y";
$description = Trim($description);
if ($ID <= 0) {
$APPLICATION->ThrowException(Loc::getMessage("SKGO_NO_ORDER_ID1"), "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["CANCELED"] == $val) {
$APPLICATION->ThrowException(str_replace("#ID#", $ID, Loc::getMessage("SKGO_DUB_CANCEL")), "ALREADY_FLAG");
return false;
}
if ($isOrderConverted == "Y") {
$r = \Bitrix\Sale\Compatible\OrderCompatibility::cancel($ID, $val, $description);
if ($r->isSuccess(true)) {
$res = true;
} else {
$errorMessage = "";
foreach ($r->getErrorMessages() as $error) {
$errorMessage .= " " . $error;
}
$APPLICATION->ThrowException(Loc::getMessage("SKGO_CANCEL_ERROR", array("#MESSAGE#" => $errorMessage)), "CANCEL_ERROR");
return false;
}
} else {
foreach (GetModuleEvents("sale", "OnSaleBeforeCancelOrder", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID, $val)) === false) {
return false;
}
}
if ($val == "Y") {
if ($arOrder["DEDUCTED"] == "Y") {
if (!CSaleOrder::DeductOrder($ID, "N")) {
return false;
}
}
if ($arOrder["RESERVED"] == "Y") {
if (!CSaleOrder::ReserveOrder($ID, "N")) {
return false;
}
}
if ($arOrder["PAYED"] == "Y") {
if (!CSaleOrder::PayOrder($ID, "N", True, True)) {
return False;
}
} else {
$arOrder["SUM_PAID"] = DoubleVal($arOrder["SUM_PAID"]);
if ($arOrder["SUM_PAID"] > 0) {
if (!CSaleUserAccount::UpdateAccount($arOrder["USER_ID"], $arOrder["SUM_PAID"], $arOrder["CURRENCY"], "ORDER_CANCEL_PART", $ID)) {
return False;
}
CSaleOrder::Update($arOrder["ID"], array("SUM_PAID" => 0));
}
}
if ($arOrder["ALLOW_DELIVERY"] == "Y") {
if (!CSaleOrder::DeliverOrder($ID, "N")) {
return False;
}
}
} else {
if (COption::GetOptionString("sale", "product_reserve_condition", "O") == "O" && $arOrder["RESERVED"] != "Y") {
if (!CSaleOrder::ReserveOrder($ID, "Y")) {
return false;
}
}
}
$arFields = array("CANCELED" => $val, "=DATE_CANCELED" => $DB->GetNowFunction(), "REASON_CANCELED" => strlen($description) > 0 ? $description : false, "EMP_CANCELED_ID" => IntVal($USER->GetID()) > 0 ? IntVal($USER->GetID()) : false);
$res = CSaleOrder::Update($ID, $arFields);
}
unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_" . $ID]);
if ($isOrderConverted != "Y") {
//this method is used only for catalogs without reservation and deduction support
CSaleBasket::OrderCanceled($ID, $val == "Y" ? True : False);
foreach (GetModuleEvents("sale", "OnSaleCancelOrder", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $val, $description));
}
}
if ($val == "Y") {
CTimeZone::Disable();
$arOrder = CSaleOrder::GetByID($ID);
CTimeZone::Enable();
$userEmail = "";
$dbOrderProp = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $ID, "PROP_IS_EMAIL" => "Y"));
if ($arOrderProp = $dbOrderProp->Fetch()) {
$userEmail = $arOrderProp["VALUE"];
}
if (strlen($userEmail) <= 0) {
$dbUser = CUser::GetByID($arOrder["USER_ID"]);
if ($arUser = $dbUser->Fetch()) {
$userEmail = $arUser["EMAIL"];
}
}
//.........这里部分代码省略.........
示例3: OrderBasket
//.........这里部分代码省略.........
$rsOrders = CSaleOrder::GetList(array(), array('ID' => $orderID), false, false, array('ID', 'USER_ID', 'RECURRING_ID', 'LID', 'RESERVED'));
if (!($arOrder = $rsOrders->Fetch())) {
return false;
}
$arOrder['RECURRING_ID'] = intval($arOrder['RECURRING_ID']);
}
$boolRecurring = 0 < $arOrder['RECURRING_ID'];
$findEmptyBasket = false;
$dbBasketList = CSaleBasket::GetList(array("PRICE" => "DESC"), array("FUSER_ID" => $fuserID, "LID" => $strLang, "ORDER_ID" => 0));
while ($arBasket = $dbBasketList->Fetch()) {
$findEmptyBasket = true;
$arFields = array();
if ($arBasket["DELAY"] == "N" && $arBasket["CAN_BUY"] == "Y") {
if (!empty($arBasket["ORDER_CALLBACK_FUNC"]) || !empty($arBasket["PRODUCT_PROVIDER_CLASS"])) {
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) {
$arQuery = array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "QUANTITY" => $arBasket["QUANTITY"]);
if ($boolRecurring) {
$arQuery['RENEWAL'] = 'Y';
$arQuery['USER_ID'] = $arOrder['USER_ID'];
$arQuery['SITE_ID'] = $strLang;
}
$arFields = $productProvider::OrderProduct($arQuery);
} else {
if ($boolRecurring) {
$arFields = CSaleBasket::ExecuteCallbackFunction($arBasket["ORDER_CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arBasket["QUANTITY"], 'Y', $arOrder['USER_ID'], $strLang);
} else {
$arFields = CSaleBasket::ExecuteCallbackFunction($arBasket["ORDER_CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arBasket["QUANTITY"]);
}
}
if ($arFields && is_array($arFields) && !empty($arFields)) {
$arFields["CAN_BUY"] = "Y";
} elseif (is_array($arFields) && empty($arFields)) {
unset($arFields);
$arFields["CAN_BUY"] = "N";
}
}
if ($arFields["CAN_BUY"] == "Y" || empty($arFields) && $arBasket["CAN_BUY"] == "Y") {
$arFields["ORDER_ID"] = $orderID;
}
if (!empty($arFields)) {
if (CSaleBasket::Update($arBasket["ID"], $arFields)) {
$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]--;
}
}
}
}
//end of while
if (!$findEmptyBasket) {
$dbBasketList = CSaleBasket::GetList(array("PRICE" => "DESC"), array("FUSER_ID" => $fuserID, "LID" => $strLang, "ORDER_ID" => $orderID));
while ($arBasket = $dbBasketList->Fetch()) {
$arFields = array();
if ($arBasket["DELAY"] == "N" && $arBasket["CAN_BUY"] == "Y") {
if (!empty($arBasket["ORDER_CALLBACK_FUNC"]) || !empty($arBasket["PRODUCT_PROVIDER_CLASS"])) {
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) {
$arQuery = array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "QUANTITY" => $arBasket["QUANTITY"]);
if ($boolRecurring) {
$arQuery['RENEWAL'] = 'Y';
$arQuery['USER_ID'] = $arOrder['USER_ID'];
$arQuery['SITE_ID'] = $strLang;
}
$arFields = $productProvider::OrderProduct($arQuery);
} else {
if ($boolRecurring) {
$arFields = CSaleBasket::ExecuteCallbackFunction($arBasket["ORDER_CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arBasket["QUANTITY"], 'Y', $arOrder['USER_ID'], $strLang);
} else {
$arFields = CSaleBasket::ExecuteCallbackFunction($arBasket["ORDER_CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arBasket["QUANTITY"]);
}
}
if ($arFields && is_array($arFields) && !empty($arFields)) {
$arFields["CAN_BUY"] = "Y";
} elseif (is_array($arFields) && empty($arFields)) {
unset($arFields);
$arFields["CAN_BUY"] = "N";
}
}
if ($arFields["CAN_BUY"] == "Y" || empty($arFields) && $arBasket["CAN_BUY"] == "Y") {
$arFields["ORDER_ID"] = $orderID;
}
if (!empty($arFields)) {
$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]--;
}
}
}
//end of while
}
if ($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID] < 0) {
$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID] = 0;
}
foreach (GetModuleEvents("sale", "OnBasketOrder", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($orderID, $fuserID, $strLang, $arDiscounts));
}
//reservation
if ($arOrder['RESERVED'] != "Y" && COption::GetOptionString("sale", "product_reserve_condition", "O") == "O") {
if (!CSaleOrder::ReserveOrder($orderID, "Y")) {
return false;
}
}
}
示例4: OrderBasket
function OrderBasket($orderID, $fuserID = 0, $strLang = SITE_ID, $arDiscounts = False)
{
$orderID = (int) $orderID;
if ($orderID <= 0) {
return false;
}
$fuserID = (int) $fuserID;
if ($fuserID <= 0) {
$fuserID = (int) CSaleBasket::GetBasketUserID(true);
}
if ($fuserID <= 0) {
return false;
}
$arOrder = array();
if (empty($arOrder)) {
$rsOrders = CSaleOrder::GetList(array(), array('ID' => $orderID), false, false, array('ID', 'USER_ID', 'RECURRING_ID', 'LID', 'RESERVED'));
if (!($arOrder = $rsOrders->Fetch())) {
return false;
}
$arOrder['RECURRING_ID'] = (int) $arOrder['RECURRING_ID'];
}
$boolRecurring = $arOrder['RECURRING_ID'] > 0;
$needSaveCoupons = false;
$dbBasketList = CSaleBasket::GetList(array("PRICE" => "DESC"), array("FUSER_ID" => $fuserID, "LID" => $strLang, "ORDER_ID" => 0), false, false, array('ID', 'ORDER_ID', 'PRODUCT_ID', 'MODULE', 'CAN_BUY', 'DELAY', 'ORDER_CALLBACK_FUNC', 'PRODUCT_PROVIDER_CLASS', 'QUANTITY'));
while ($arBasket = $dbBasketList->Fetch()) {
$arFields = array();
if ($arBasket["DELAY"] == "N" && $arBasket["CAN_BUY"] == "Y") {
if (!empty($arBasket["ORDER_CALLBACK_FUNC"]) || !empty($arBasket["PRODUCT_PROVIDER_CLASS"])) {
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) {
$arQuery = array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "QUANTITY" => $arBasket["QUANTITY"], 'BASKET_ID' => $arBasket['ID']);
if ($boolRecurring) {
$arQuery['RENEWAL'] = 'Y';
$arQuery['USER_ID'] = $arOrder['USER_ID'];
$arQuery['SITE_ID'] = $strLang;
}
$arFields = $productProvider::OrderProduct($arQuery);
} else {
if ($boolRecurring) {
$arFields = CSaleBasket::ExecuteCallbackFunction($arBasket["ORDER_CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arBasket["QUANTITY"], 'Y', $arOrder['USER_ID'], $strLang);
} else {
$arFields = CSaleBasket::ExecuteCallbackFunction($arBasket["ORDER_CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arBasket["QUANTITY"]);
}
}
if (!empty($arFields) && is_array($arFields)) {
$arFields["CAN_BUY"] = "Y";
$arFields["ORDER_ID"] = $orderID;
$needSaveCoupons = true;
} else {
$arFields = array('CAN_BUY' => 'N');
$removeCoupon = DiscountCouponsManager::deleteApplyByProduct(array('MODULE' => $arBasket['MODULE'], 'PRODUCT_ID' => $arBasket['PRODUCT_ID'], 'BASKET_ID' => $arBasket['ID']));
}
} else {
$arFields["ORDER_ID"] = $orderID;
$needSaveCoupons = true;
}
if (!empty($arFields)) {
if (CSaleBasket::Update($arBasket["ID"], $arFields)) {
$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]--;
}
}
}
}
//end of while
if ($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID] < 0) {
$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID] = 0;
}
foreach (GetModuleEvents("sale", "OnBasketOrder", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($orderID, $fuserID, $strLang, $arDiscounts));
}
if ($needSaveCoupons) {
DiscountCouponsManager::finalApply();
DiscountCouponsManager::saveApplied();
}
//reservation
if ($arOrder['RESERVED'] != "Y" && COption::GetOptionString("sale", "product_reserve_condition") == "O") {
if (!CSaleOrder::ReserveOrder($orderID, "Y")) {
return false;
}
}
return true;
}
示例5: OrderBasket
function OrderBasket($orderID, $fuserID = 0, $strLang = LANG, $arDiscounts = False)
{
global $DB, $APPLICATION;
$orderID = IntVal($orderID);
if ($orderID <= 0) {
return False;
}
$fuserID = IntVal($fuserID);
if ($fuserID <= 0) {
$fuserID = CSaleBasket::GetBasketUserID();
}
$dbBasketList = CSaleBasket::GetList(array("PRICE" => "DESC"), array("FUSER_ID" => $fuserID, "LID" => $strLang, "ORDER_ID" => 0));
while ($arBasket = $dbBasketList->Fetch()) {
/*
if (strlen($arBasket["CALLBACK_FUNC"]) > 0)
{
CSaleBasket::UpdatePrice($arBasket["ID"], $arBasket["CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arBasket["QUANTITY"]);
$arBasket = CSaleBasket::GetByID($arBasket["ID"]);
}
*/
$arFields = array();
if ($arBasket["DELAY"] == "N" && $arBasket["CAN_BUY"] == "Y") {
if (strlen($arBasket["ORDER_CALLBACK_FUNC"]) > 0 || strlen($arBasket["PRODUCT_PROVIDER_CLASS"])) {
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) {
$arFields = $productProvider::OrderProduct(array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "QUANTITY" => $arBasket["QUANTITY"]));
} else {
$arFields = CSaleBasket::ExecuteCallbackFunction($arBasket["ORDER_CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arBasket["QUANTITY"], $orderID);
}
if ($arFields && is_array($arFields) && count($arFields) > 0) {
$arFields["CAN_BUY"] = "Y";
} elseif (is_array($arFields) && count($arFields) <= 0) {
unset($arFields);
$arFields["CAN_BUY"] = "N";
}
}
if ($arFields["CAN_BUY"] == "Y" || empty($arFields) && $arBasket["CAN_BUY"] == "Y") {
$arFields["ORDER_ID"] = $orderID;
//if ($arDiscounts && is_array($arDiscounts) && count($arDiscounts) > 0)
//$arFields["DISCOUNT_PRICE"] = $arDiscounts[IntVal($arBasket["ID"])];
}
if (!empty($arFields)) {
if (CSaleBasket::Update($arBasket["ID"], $arFields)) {
$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]--;
}
}
}
}
//end of while
if ($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID] < 0) {
$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID] = 0;
}
//reservation
if (COption::GetOptionString("sale", "product_reserve_condition", "O") == "O") {
if (!CSaleOrder::ReserveOrder($orderID, "Y")) {
return false;
}
}
//$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID] = 0;
foreach (GetModuleEvents("sale", "OnBasketOrder", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($orderID, $fuserID, $strLang, $arDiscounts));
}
}