当前位置: 首页>>代码示例>>PHP>>正文


PHP CSaleBasket::OrderReservation方法代码示例

本文整理汇总了PHP中CSaleBasket::OrderReservation方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleBasket::OrderReservation方法的具体用法?PHP CSaleBasket::OrderReservation怎么用?PHP CSaleBasket::OrderReservation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSaleBasket的用法示例。


在下文中一共展示了CSaleBasket::OrderReservation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:58,代码来源:order.php

示例2: 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;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:50,代码来源:order.php

示例3: 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();";
	}
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:66,代码来源:order.php


注:本文中的CSaleBasket::OrderReservation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。