OrderStatusLog::onBeforeWrite PHP Method

onBeforeWrite() public method

public onBeforeWrite ( )
    public function onBeforeWrite()
    {
        parent::onBeforeWrite();
        if (!$this->AuthorID && ($memberID = Member::currentUserID())) {
            $this->AuthorID = $memberID;
        }
        if (!$this->Title) {
            $this->Title = "Order Update";
        }
    }

Usage Example

 /**
  * adding a sequential order number.
  */
 function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if ($order = $this->Order()) {
         if (!$this->Total) {
             $this->Total = $order->Total();
             $this->SubTotal = $order->SubTotal();
         }
     }
     if (!intval($this->SequentialOrderNumber)) {
         $this->SequentialOrderNumber = 1;
         $min = intval(EcommerceConfig::get("Order", "order_id_start_number")) - 0;
         if (isset($this->ID)) {
             $id = intval($this->ID);
         } else {
             $id = 0;
         }
         $lastOne = OrderStatusLog_Submitted::get()->Exclude(array("ID" => $id))->Sort("SequentialOrderNumber", "DESC")->First();
         if ($lastOne) {
             $this->SequentialOrderNumber = intval($lastOne->SequentialOrderNumber) + 1;
         }
         if (intval($min) && $this->SequentialOrderNumber < $min) {
             $this->SequentialOrderNumber = $min;
         }
     }
 }
All Usage Examples Of OrderStatusLog::onBeforeWrite