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


PHP CSaleBasket::OrderCanceled方法代码示例

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


在下文中一共展示了CSaleBasket::OrderCanceled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:order.php

示例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"];
             }
         }
//.........这里部分代码省略.........
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:101,代码来源:order.php


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