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
Deon George 04ebda2aaa Theme work with focusbusiness and baseadmin
Improvements to NAVBAR, updates to StaticList methods, other minor items
Enable product category rendering and other minor improvements
Added ADSL-large category price plan
2013-10-10 13:56:13 +11:00

76 lines
1.8 KiB
PHP

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports a product cart
*
* @package Cart
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @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 $_serialize_column = array(
'module_data',
);
/**
* Filters used to format the display of values into friendlier values
*/
protected $_display_filters = array(
'recurr_schedule'=>array(
array('StaticList_RecurSchedule::get',array(':value')),
),
);
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)));
}
}
?>