2010-11-29 22:41:08 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class supports a product cart
|
|
|
|
*
|
2013-03-19 22:35:19 +00:00
|
|
|
* @package Cart
|
2010-11-29 22:41:08 +00:00
|
|
|
* @category Models
|
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
2010-11-29 22:41:08 +00:00
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
2012-12-10 21:48:30 +00:00
|
|
|
class Model_Cart extends ORM_OSB {
|
2010-11-29 22:41:08 +00:00
|
|
|
protected $_belongs_to = array(
|
|
|
|
'product'=>array(),
|
|
|
|
);
|
|
|
|
|
|
|
|
// Cart doesnt use the update column
|
|
|
|
protected $_updated_column = FALSE;
|
2011-05-14 07:35:33 +00:00
|
|
|
|
2013-01-15 06:07:54 +00:00
|
|
|
protected $_serialize_column = array(
|
|
|
|
'module_data',
|
|
|
|
);
|
|
|
|
|
2011-05-14 07:35:33 +00:00
|
|
|
/**
|
|
|
|
* Filters used to format the display of values into friendlier values
|
|
|
|
*/
|
|
|
|
protected $_display_filters = array(
|
|
|
|
'recurr_schedule'=>array(
|
2013-04-26 01:42:09 +00:00
|
|
|
array('StaticList_RecurSchedule::get',array(':value')),
|
2011-05-14 07:35:33 +00:00
|
|
|
),
|
|
|
|
);
|
2013-01-15 06:07:54 +00:00
|
|
|
|
|
|
|
private $mo;
|
|
|
|
|
|
|
|
public function __construct($id = NULL) {
|
|
|
|
// Load our Model
|
|
|
|
parent::__construct($id);
|
|
|
|
|
|
|
|
// Autoload our Sub Items
|
|
|
|
if ($this->loaded())
|
|
|
|
$this->_load_sub_items();
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function _load_sub_items() {
|
|
|
|
$this->mo = ORM::factory('Module',$this->module_id)->instance($this->module_item);
|
|
|
|
|
|
|
|
if (! $this->mo->loaded())
|
|
|
|
throw new Kohana_Exception('Item :item not loaded?',array(':item'=>$this->module_item));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkout() {
|
|
|
|
if (! method_exists($this->mo,'checkout'))
|
|
|
|
throw new Kohana_Exception('Module :module doesnt implement checkout?',array(':module'=>get_class($this->mo)));
|
|
|
|
|
|
|
|
return $this->mo->checkout();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function item() {
|
|
|
|
if (! method_exists($this->mo,'cart_item'))
|
|
|
|
throw new Kohana_Exception('Module :module doesnt implement cart_item?',array(':module'=>get_class($this->mo)));
|
|
|
|
|
|
|
|
return $this->mo->cart_item();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function mo() {
|
|
|
|
return $this->mo;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function motype() {
|
|
|
|
return strtolower(preg_replace('/^Model_/','',get_class($this->mo)));
|
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
?>
|