<?php defined('SYSPATH') or die('No direct access allowed.'); /** * This class provides a order cart * * @package Cart * @category Controllers * @author Deon George * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ class Controller_Cart extends Controller_TemplateDefault { protected $auth_required = FALSE; /** * List the cart contents */ public function action_index() { $co = Cart::instance(); // If the cart is empty, we'll return here. if (! $co->contents()->count()) $this->template->content = _('Cart is Empty'); else { $output = View::factory('cart/view')->set('o',$co); $output .= Form::open('checkout/before'); $output .= View::factory('cart/payment')->set('o',$co); $output .= Form::close(); Block::factory() ->body($output); } } /** * Add an item to the cart */ public function action_add() { $co = ORM::factory('Cart'); $co->values(Request::current()->post()); $co->session_id = Session::instance()->id(); if (! $this->save($co)) throw HTTP_Exception::factory(501,_('There was a problem adding the item to the cart.')); HTTP::redirect('cart/index'); } public function action_empty() { Cart::instance()->delete(); $this->template->content = _('Cart Emptied'); } } ?>