/** * Populate some OrderItem object attributes before * writing them to the OrderItem DB record. * * PRECONDITION: The order item is not saved in the database yet. */ function onBeforeWrite() { parent::onBeforeWrite(); //always keep quantity above 0 if ($this->Quantity < 1) { $this->Quantity = 1; } $this->CalculateTotal(); }
/** * Recalculate total before saving to database. */ public function onBeforeWrite() { parent::onBeforeWrite(); if ($this->OrderID && $this->Order() && $this->Order()->isCart()) { $this->calculatetotal(); } }
/** * standard SS method */ function onBeforeWrite() { parent::onBeforeWrite(); }
/** * Before this OrderModifier is written to * the database, we set some of the fields * based on the way it was set up * {@link OrderModifier::is_chargable()}. * * Precondition: The order item is not * saved in the database yet. */ function onBeforeWrite() { parent::onBeforeWrite(); $this->Amount = $this->Amount(); $this->Type = $this->stat('is_chargable') ? 'Chargable' : 'Deductable'; }
/** * Standard SS method. * If the quantity is zero then we set it to 1. * TODO: evaluate this rule. */ function onBeforeWrite() { if (!$this->exists()) { if ($buyable = $this->Buyable(true)) { if ($this->ClassName == "OrderItem" && $this->BuyableClassName != "OrderItem") { $this->setClassName($buyable->classNameForOrderItem()); } } } //now we can do the parent thing parent::onBeforeWrite(); //always keep quantity above 0 if (floatval($this->Quantity) == 0) { $this->Quantity = 1; } if (!$this->Version && ($buyable = $this->Buyable(true))) { $this->Version = $buyable->Version; } }
/** * Populate some OrderItem object attributes before * writing them to the OrderItem DB record. * * PRECONDITION: The order item is not saved in the database yet. */ function onBeforeWrite() { parent::onBeforeWrite(); $this->Quantity = $this->_quantity; }