Location: PHPKode > projects > HikaShop > front/controllers/product.php
<?php
/**
 * @package		HikaShop for Joomla!
 * @version		1.4.3
 * @author		hikashop.com
 * @copyright	(C) 2010 HIKARI SOFTWARE. All rights reserved.
 * @license		GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?>
<?php
class productController extends hikashopController{
	function __construct($config = array()){
		parent::__construct($config);
		$this->display[]='updatecart';
		$this->display[]='cart';
		$this->display[]='cleancart';
	}
	function authorize($task){
		if($this->isIn($task,array('display'))){
			return true;
		}
		return false;
	}
	function cleancart(){
		$class = hikashop::get('class.cart');
		if($class->hasCart()){
			$class->delete($class->cart->cart_id);
		}
		$url = JRequest::getVar('url','');
		if(!empty($url)){
			$url = urldecode($url);
			$this->setRedirect($url);
		}else{
			echo '<html><head><script type="text/javascript">history.go(-1);</script></head><body></body></html>';
			exit;
		}
	}
	function updatecart(){
		$char = JRequest::getString('characteristic','');
		if(!empty($char)){
			return $this->show();
		}else{
			$formData = JRequest::getVar( 'data', array(), '', 'array' );
			$add = JRequest::getCmd('add','');
			if(!empty($add)){
				$add=1;
			}else{
				$add=0;
			}
			if(!empty($formData)){
				$class = hikashop::get('class.cart');
				$class->update($formData,0,$add);
			}else{
				$product_id = JRequest::getCmd('product_id',0);
				$quantity = JRequest::getInt('quantity',1);
				if(!empty($product_id)){
					$type = JRequest::getWord('type','product');
					if($type=='product'){
						$product_id=(int)$product_id;
					}
					$class = hikashop::get('class.cart');
					$class->update($product_id,$quantity,$add,$type);
				}
			}
			$checkout = JRequest::getString('checkout','');
			if(!empty($checkout)){
				global $Itemid;
				$url = 'checkout';
				if(!empty($Itemid)){
					$url.='&Itemid='.$Itemid;
				}
				$url = hikashop::completeLink($url,false,true);
				$this->setRedirect($url);
			}else{
				$tmpl = JRequest::getCmd('tmpl','index');
				if($tmpl=='component'){
					$js ='';
					jimport('joomla.application.module.helper');
					global $Itemid;
					if(isset($Itemid) && empty($Itemid)){
						$Itemid=null;
						JRequest::setVar('Itemid',null);
					}
					$module = JModuleHelper::getModule('hikashop_cart',false);
					$config =& hikashop::config();
					jimport('joomla.html.parameter');
					$params = new JParameter( @$module->params );
					if(!empty($module)){
						$module_options = $config->get('params_'.$module->id);
					}
					if(empty($module_options)){
						$module_options = $config->get('default_params');
					}
					foreach($module_options as $key => $option){
						$params->set($key,$option);
					}
					if(!empty($module)){
						foreach(get_object_vars($module) as $k => $v){
							if(!is_object($v)){
								$params->set($k,$v);
							}
						}
					}
					hikashop::getLayout('product','cart',$params,$js);
					return true;
				}else{
					$url = JRequest::getVar('url','');
					if(!empty($url)){
						$url = urldecode($url);
					}else{
						global $Itemid;
						$url = 'checkout';
						if(!empty($Itemid)){
							$url.='&Itemid='.$Itemid;
						}
						$url = hikashop::completeLink($url,false,true);
					}
					$this->setRedirect($url);
					return false;
				}
			}
		}
	}
}
Return current item: HikaShop