Bitrix Site Manager

CSaleOrder::PayOrder

int
CSaleOrder::PayOrder(
  int ID,
  string Val
);

The method PayOrder changes the value of the PAYED field (sets the order as paid). Besides, it sets the fields DATE_PAYED (date when the order was paid) and EMP_PAYED_ID (the ID of a user (web shop member) who sets this flag).

Parameters

ParameterDescription
IDThe order ID.
ValNew value of the order payment flag (Y/N).

Return Values

Returns the order ID on success, or false otherwise.

Example



<?
if (!CSaleOrder::PayOrder($ID, "Y"))
{
   echo "Error updating order";
}
else
{
   // Register the purchase event
   if (CModule::IncludeModule("statistic"))
   {
      if (method_exists("CStatEvent", "AddByEvents"))
      {
         $arOrder_tmp = CSaleOrder::GetByID($ID);
         $orderPrice_tmp = DoubleVal($arOrder_tmp["PRICE"]);
         CStatEvent::AddByEvents("sale2order",
                                 "payment", 
                                 $ID, 
                                 "", 
                                 $arOrder_tmp["STAT_GID"], 
                                 $orderPrice_tmp, 
                                 $arOrder_tmp["CURRENCY"]);
      }
   }
}
?>