OrderItem::onBeforeWrite PHP Method

onBeforeWrite() public method

Recalculate total before saving to database.
public onBeforeWrite ( )
    public function onBeforeWrite()
    {
        parent::onBeforeWrite();
        if ($this->OrderID && $this->Order() && $this->Order()->isCart()) {
            $this->calculatetotal();
        }
    }

Usage Example

 function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $this->ProductID = $this->_productID;
     $this->ProductVersion = $this->_productVersion;
 }