public function runUpdate($recalculate = false) { if (!$this->IsRemoved()) { $this->checkField("Name"); $this->checkField("CalculatedTotal"); $this->checkField("TableValue"); if ($this->mustUpdate && $this->canBeUpdated()) { $this->write(); } $this->runningTotal += $this->CalculatedTotal; } parent::runUpdate($recalculate); }
/** * saves details about the Order Item before the order is submittted * @param Bool $recalculate - run it, even if it has run already **/ function runUpdate($recalculate = false) { $buyable = $this->Buyable(true); if ($buyable && $buyable->canPurchase()) { if (isset($buyable->Version)) { if ($this->Version != $buyable->Version) { $this->Version = $buyable->Version; $this->write(); } } $oldValue = $this->CalculatedTotal - 0; $newValue = $this->getUnitPrice() * $this->Quantity - 0; if (round($newValue, 5) != round($oldValue, 5) || $recalculate) { $this->CalculatedTotal = $newValue; $this->write(); } } else { //if it can not be purchased or it does not exist //then we do not accept it!!!! $this->delete(); user_error("Product added to cart can not be purchased. It has been deleted."); } return parent::runUpdate($recalculate); }