This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/cart/classes/Model/Cart.php

76 lines
1.8 KiB
PHP
Raw Normal View History

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
*/
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
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(
array('StaticList_RecurSchedule::get',array(':value')),
2011-05-14 07:35:33 +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
}
?>