/** * */ public function remove($quoteID, $productID) { // Remove the product from the quote $where = $this->quoteInto('quote_id = ? AND product_id = ?', $quoteID, $productID); $this->delete($where); // Clean up meta data $quoteProductMetas = new Datasource_Insurance_Quote_Product_Metas(); $quoteProductMetas->cleanup($quoteID, $productID); }
/** * Add contents insurance to the quote * * @param boolean furnished True or False depending on whether the property is furnished * @param string accidentalDamage Add accidental damage cover? * @param int coverAmount The amount to be insured (optional!) * @param int excess The chosen excess (optional!) */ public function addContentsCover($furnished, $accidentalDamage = null, $coverAmount = null, $excess = null) { // Check to see if the product is already added to this quote - if it is remove it if ($this->hasProduct(self::UNFURNISHED_CONTENTS_COVER)) { $this->removeProduct(self::UNFURNISHED_CONTENTS_COVER); } if ($this->hasProduct(self::CONTENTS_COVER)) { $this->removeProduct(self::CONTENTS_COVER); } // Remove any emergency assistance that may be on the quote as you get that for free if ($this->hasProduct(self::EMERGENCY_ASSISTANCE) && !$this->hasProduct(self::BUILDING_COVER)) { $this->removeProduct(self::EMERGENCY_ASSISTANCE); } $quoteProducts = new Datasource_Insurance_Quote_Products(); if ($furnished) { // Furnished contents cover // Add this product to the quote $quoteProducts->add($this->_quoteModel->ID, self::CONTENTS_COVER); // Now we need to add all the relevant meta data $quoteProductMetas = new Datasource_Insurance_Quote_Product_Metas(); $quoteProductMetas->add($this->_quoteModel->ID, self::CONTENTS_COVER, 'cover_amount', $coverAmount); $quoteProductMetas->add($this->_quoteModel->ID, self::CONTENTS_COVER, 'excess', $excess); $quoteProductMetas->add($this->_quoteModel->ID, self::CONTENTS_COVER, 'accidental_damage', $accidentalDamage); // Add on free emergency assistance if (!$this->hasProduct(self::BUILDING_COVER)) { $quoteProducts->add($this->_quoteModel->ID, self::EMERGENCY_ASSISTANCE); } } else { // Unfurnished contents cover // Add this product to the quote $quoteProducts->add($this->_quoteModel->ID, self::UNFURNISHED_CONTENTS_COVER); } $this->save(); }
/** * Returns an array of meta data for a specific product * * @param $productID * @return array Associative array of meta data */ public function getProductMeta($productID) { $quoteProductMetas = new Datasource_Insurance_Quote_Product_Metas(); return $quoteProductMetas->getByProductID($this->_quoteModel->ID, $productID); }