Internal overhaul of Cart/Checkout and other minor fixes
This commit is contained in:
@@ -10,13 +10,14 @@
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Cart extends ORM_OSB {
|
||||
protected $_belongs_to = array(
|
||||
'product'=>array(),
|
||||
);
|
||||
|
||||
// Cart doesnt use the update column
|
||||
protected $_updated_column = FALSE;
|
||||
|
||||
protected $_belongs_to = array(
|
||||
'product'=>array(),
|
||||
'module'=>array(),
|
||||
);
|
||||
|
||||
protected $_serialize_column = array(
|
||||
'module_data',
|
||||
);
|
||||
@@ -30,46 +31,26 @@ class Model_Cart extends ORM_OSB {
|
||||
),
|
||||
);
|
||||
|
||||
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'))
|
||||
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();
|
||||
return $this->mo()->checkout();
|
||||
}
|
||||
|
||||
public function item() {
|
||||
if (! method_exists($this->mo,'cart_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();
|
||||
return $this->mo()->cart_item();
|
||||
}
|
||||
|
||||
public function mo() {
|
||||
return $this->mo;
|
||||
return $this->module->instance($this->module_item);
|
||||
}
|
||||
|
||||
public function motype() {
|
||||
return strtolower(preg_replace('/^Model_/','',get_class($this->mo)));
|
||||
return strtolower(preg_replace('/^Model_/','',get_class($this->mo())));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user