Location: PHPKode > projects > HikaShop > back/classes/cart.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 hikashopCartClass extends hikashopClass{
	var $tables = array('cart_product','cart');
	var $pkeys = array('cart_id','cart_id');
	function hasCart($cart_id=0){
		$this->loadCart($cart_id);
		if(!empty($this->cart->cart_id)){
			return true;
		}
		return false;
	}
	function loadCart($cart_id=0,$reset=false){
		static $carts = array();
		if($reset){
			$carts = array();
			return true;
		}
		$this->filters = array();
		$app =& JFactory::getApplication();
		if(empty($cart_id)){
			$this->cart_id = $app->getUserStateFromRequest( HIKASHOP_COMPONENT.'.cart_id', 'cart_id', 0, 'int' );
		}else{
			$this->cart_id=$cart_id;
		}
		if(!empty($this->cart_id)){
			$this->filters[]='a.cart_id = '.(int)$this->cart_id;
		}else{
			$user = JFactory::getUser();
			if(!empty($user->id)){
				$this->filters[]='a.user_id = '.(int)$user->id;
			}
			$session = JFactory::getSession();
			if($session->getId()){
				$this->filters[]='a.session_id = '.$this->database->Quote($session->getId());
			}
		}
		$filter = implode(' OR ',$this->filters);
		if(!empty($carts[$filter])){
			$this->cart =& $carts[$filter];
		}else{
			$query='SELECT a.* FROM '.hikashop::table('cart').' AS a WHERE '.$filter.' ORDER BY a.cart_modified DESC LIMIT 1';
			$this->database->setQuery($query);
			$this->cart = $this->database->loadObject();
			$carts[$filter] =& $this->cart;
		}
	}
	function & get($cart_id=0){	
		$result = false;	
		if($this->hasCart($cart_id)){
			$filters=array('b.cart_id = '.$this->cart->cart_id,'b.product_id > 0');
			hikashop::addACLFilters($filters,'product_access','c');
			$query='SELECT b.*,c.* FROM '.hikashop::table('cart_product').' AS b LEFT JOIN '.hikashop::table('product').' AS c ON b.product_id=c.product_id WHERE '.implode(' AND ',$filters).' ORDER BY c.product_parent_id ASC,b.cart_product_modified ASC';
			$this->database->setQuery($query);
			$products = $this->database->loadObjectList('product_id');
			if(empty($products)){
				$this->delete($this->cart->cart_id);
				$app =& JFactory::getApplication();
				$app->setUserState(HIKASHOP_COMPONENT.'.cart_id', 0);
				$this->cart = null;
			}
			return $products;
		}
		return $result;
	}
	function addToCartFromFields(&$entriesData,&$fields){
		$this->resetCart(false);
		$app =& JFactory::getApplication();
		$productsToAdd = array();
		$coupons = array();
		foreach($entriesData as $entryData){
			foreach(get_object_vars($entryData) as $namekey=>$value){
				foreach($fields as $field){
					if($field->field_namekey==$namekey){
						$ok = false;
						if(!empty($field->field_options['product_id'])){
							if(is_numeric($value) && is_numeric($field->field_options['product_value'])){
								if( $value === $field->field_options['product_value'] ){
									$ok = true;
								}
							}elseif($value == $field->field_options['product_value']){
								$ok = true;
							}
							if($ok){
								$id = $field->field_options['product_id'];
								if(empty($productsToAdd[$id])){
									$productsToAdd[$id]=1;
								}else{
									$productsToAdd[$id]++;
								}
							}
						}
						if($field->field_type=='coupon' && !empty($field->coupon[$value])){
							$coupons[] = $field->coupon[$value];
						}
						break;
					}
				}
			}
		}
		if(!empty($productsToAdd)){
			$array = array();
			foreach($productsToAdd as $id => $qty){
				$this->updateEntry($qty,$array,$id,0,false);
			}
		}
		if(count($coupons)>1){
			$total = 0.0;
			$currency = hikashop::getCurrency();
			$currencyClass = hikashop::get('class.currency');
			$discountClass = hikashop::get('class.discount');
			foreach($coupons as $item){
				$currencyClass->convertCoupon($item,$currency);
				$total = $total + $item->discount_flat_amount;
				$this->database->setQuery('UPDATE '.hikashop::table('discount').' SET discount_used_times=discount_used_times+1 WHERE discount_id = '.$item->discount_id);
				$this->database->query();
			}
			$newCoupon = null;
			$newCoupon->discount_type='coupon';
			$newCoupon->discount_currency_id = $currency;
			$newCoupon->discount_flat_amount = $total;
			$newCoupon->discount_quota = 1;
			jimport('joomla.user.helper');
			$newCoupon->discount_code = JUserHelper::genRandomPassword(30); 
			$newCoupon->discount_published = 1;
			$discountClass->save($newCoupon);
			$coupon = $newCoupon;
		}elseif(count($coupons)==1){
			$coupon = reset($coupons);
		}
		if(!empty($coupon)){
			$this->update($coupon->discount_code,1,0,'coupon',false);
		}
		$this->loadCart(0,true);
		$app->setUserState( HIKASHOP_COMPONENT.'.shipping_method',0);
		$app->setUserState( HIKASHOP_COMPONENT.'.shipping_id',0);
		$app->setUserState( HIKASHOP_COMPONENT.'.shipping_data',0);
	}
	function initCart(){
		$cart = null;
		if(!empty($this->cart->cart_id)){
			$cart->cart_id = $this->cart->cart_id;
		}
		$user = JFactory::getUser();
		if(empty($user->id)){
			$session = JFactory::getSession();
			if($session->getId()){
				$cart->session_id = $session->getId();
			}
		}else{
			$cart->user_id = $user->id;
			$cart->session_id = '';
		}
		$cart->cart_modified=time();
		$this->cart->cart_id=(int)$this->save($cart);
		return $cart;
	}
	function resetCart($reset=true){
		$cartContent =& $this->get();
		$cart = $this->initCart();
		$app =& JFactory::getApplication();
		$app->setUserState( HIKASHOP_COMPONENT.'.entries_fields',null);
		if(!empty($cartContent)){
			foreach($cartContent as $id => $product){
				if(!empty($cartContent[$id]->cart_product_quantity)){
					$this->updateEntry(0,$cartContent,$id,0,false);
				}
			}
		}
		if(!empty($this->cart->cart_coupon)){
			$app->setUserState( HIKASHOP_COMPONENT.'.coupon_code',$this->cart->cart_coupon);
			$this->update('',0,0,'coupon',false);
			$app->setUserState( HIKASHOP_COMPONENT.'.coupon_code','');
		}
		$app->setUserState( HIKASHOP_COMPONENT.'.shipping_method',0);
		$app->setUserState( HIKASHOP_COMPONENT.'.shipping_id',0);
		$app->setUserState( HIKASHOP_COMPONENT.'.shipping_data',0);
		if($reset){
			$this->loadCart(0,true);
		}
	}
	function update($product_id,$quantity=1,$add=0,$type='product',$resetCartWhenUpdate=true){
		if($type=='product' && empty($product_id))return false;
		$cartContent =& $this->get();	
		$app =& JFactory::getApplication();
		$entries = $app->getUserState(HIKASHOP_COMPONENT.'.entries_fields');
		if(!empty($entries)){
			if(JRequest::getVar('tmpl','')!='component'){
			}
			return false;
		}
		$cart = $this->initCart();
		if($this->cart->cart_id){
			$app->setUserState(HIKASHOP_COMPONENT.'.cart_id', $this->cart->cart_id);
		}
		if($type=='product'){
			if(!is_array($product_id)){
				$product_id=array($product_id=>$quantity);
			}
			$updated = false;
			foreach($product_id as $id => $qty){
				if($this->updateEntry((int)$qty,$cartContent,(int)$id,$add,false)){
					$updated = true;
				}
			}
			if($updated && $resetCartWhenUpdate){
				$this->loadCart(0,true);
				$app->setUserState( HIKASHOP_COMPONENT.'.shipping_method',0);
				$app->setUserState( HIKASHOP_COMPONENT.'.shipping_id',0);
				$app->setUserState( HIKASHOP_COMPONENT.'.shipping_data',0);
			}
			return $updated;
		}else{
			if($quantity){
				$new_coupon=$product_id;
			}else{
				$new_coupon='';
			}
			$old_coupon = $app->getUserState( HIKASHOP_COMPONENT.'.coupon_code','');
			if($old_coupon == $new_coupon){
				return false;
			}
			$cart->cart_coupon = $new_coupon;
			$this->cart->cart_coupon = $new_coupon;
			if($this->save($cart)){
				if(!$quantity){
					if(!empty($product_id)){
						$message = JText::_('COUPON_REMOVED');
						$app->enqueueMessage( $message );
					}
				}
				if($resetCartWhenUpdate){
					$this->loadCart(0,true);
					$app->setUserState( HIKASHOP_COMPONENT.'.coupon_code',$new_coupon);
					$app->setUserState( HIKASHOP_COMPONENT.'.shipping_method',0);
					$app->setUserState( HIKASHOP_COMPONENT.'.shipping_id',0);
					$app->setUserState( HIKASHOP_COMPONENT.'.shipping_data',0);
				}
				return true;
			}
		}
		return false;
	}
	function updateEntry($quantity,&$cartContent,$product_id,$add,$resetCartWhenUpdate=true){
		if(empty($product_id)) return false;
		if($quantity){
			if(!empty($cartContent) && in_array($product_id,array_keys($cartContent))){
				if($add){
					$quantity+=$cartContent[$product_id]->cart_product_quantity;
					$add=0;
				}elseif($quantity==$cartContent[$product_id]->cart_product_quantity){
					return false;
				}
				$this->_checkQuantity($cartContent[$product_id],$quantity,$cartContent);
				if($quantity){
					$query = 'UPDATE '.hikashop::table('cart_product').' SET cart_product_modified=\''.time().'\',cart_product_quantity='.(int)$quantity.' WHERE cart_product_id='.$cartContent[$product_id]->cart_product_id;
					$this->database->setQuery($query);
					$this->database->query();
					if($resetCartWhenUpdate){
						$this->loadCart(0,true);
						$app =& JFactory::getApplication();
						$app->setUserState( HIKASHOP_COMPONENT.'.shipping_method',0);
						$app->setUserState( HIKASHOP_COMPONENT.'.shipping_id',0);
						$app->setUserState( HIKASHOP_COMPONENT.'.shipping_data',0);
					}
					return true;
				}
			}elseif($this->cart->cart_id){
				$class = hikashop::get('class.product');
				$product = $class->get($product_id);
				$parent = 0;
				$this->_checkQuantity($product,$quantity,$cartContent);
				if($quantity){
					if($product->product_type=='variant'){
						$query = 'INSERT INTO '.hikashop::table('cart_product').' (cart_id,cart_product_modified,product_id,cart_product_parent_id,cart_product_quantity) VALUES ( '.$this->cart->cart_id.','.time().','.(int)$product->product_parent_id.',0,0)';
						$this->database->setQuery($query);
						$this->database->query();
						$parent = (int)$this->database->insertid();
					}
					$query = 'INSERT INTO '.hikashop::table('cart_product').' (cart_id,cart_product_modified,product_id,cart_product_parent_id,cart_product_quantity) VALUES ( '.$this->cart->cart_id.','.time().','.(int)$product_id.','.$parent.','.(int)$quantity.')';
					$this->database->setQuery($query);
					$this->database->query();
					if($resetCartWhenUpdate){
						$this->loadCart(0,true);
						$app =& JFactory::getApplication();
						$app->setUserState( HIKASHOP_COMPONENT.'.shipping_method',0);
						$app->setUserState( HIKASHOP_COMPONENT.'.shipping_id',0);
						$app->setUserState( HIKASHOP_COMPONENT.'.shipping_data',0);
					}
					return true;
				}
			}
		}
		if(!$add && !empty($cartContent) && in_array($product_id,array_keys($cartContent))){
			$query = 'DELETE FROM '.hikashop::table('cart_product').' WHERE cart_product_id = '.$cartContent[$product_id]->cart_product_id. ' OR cart_product_parent_id = '.$cartContent[$product_id]->cart_product_id.' OR cart_product_id = '.$cartContent[$product_id]->cart_product_parent_id;
			$this->database->setQuery($query);
			$this->database->query();
			if($resetCartWhenUpdate){
				$this->loadCart(0,true);
				$app =& JFactory::getApplication();
				$app->setUserState( HIKASHOP_COMPONENT.'.shipping_method',0);
				$app->setUserState( HIKASHOP_COMPONENT.'.shipping_id',0);
				$app->setUserState( HIKASHOP_COMPONENT.'.shipping_data',0);
			}
			return true;
		}
		return false;
	}
	function _checkQuantity(&$product,&$quantity,&$cartContent){
		if($quantity<0){
			$quantity = 0;
		}
		if(hikashop::level(1)){
			$config =& hikashop::config();
			$item_limit = $config->get('cart_item_limit',0);
			if(!empty($item_limit)){
				$current_items = 0;
				if(!empty($cartContent)){
					foreach($cartContent as $element){
						if($element->product_id!=$product->product_id) $current_items+=(int)$element->cart_product_quantity;
					}
				}
				$possible_quantity = $item_limit - $current_items;
				if($quantity > $possible_quantity){
					if($possible_quantity<0){
						$possible_quantity=0;
					}
					$quantity=$possible_quantity;
				}
			}
		}
		if($product->product_type=='variant'){
			$class = hikashop::get('class.product');
			$parentProduct = $class->get($product->product_parent_id);
			if($product->product_quantity==-1 && $parentProduct->product_quantity!=-1){
				$product->product_quantity = $parentProduct->product_quantity;
			}
			if(empty($product->product_max_per_order) && !empty($parentProduct->product_max_per_order)){
				$product->product_max_per_order = $parentProduct->product_max_per_order;
			}
		}
		if($product->product_quantity>=0 && $product->product_quantity<$quantity) $quantity = $product->product_quantity;
		if($product->product_max_per_order>0 && $product->product_max_per_order<$quantity) $quantity = $product->product_max_per_order;
	}
	function &loadFullCart($addtionalInfos=false){
		$app =& JFactory::getApplication();
		$database	=& JFactory::getDBO();
		$config =& hikashop::config();
		$currencyClass = hikashop::get('class.currency');
		$productClass = hikashop::get('class.product');
		$main_currency = (int)$config->get('main_currency',1);
		$currency_id = hikashop::getCurrency();
		if(!in_array($currency_id,$currencyClass->publishedCurrencies())){
			$currency_id = $main_currency;
		}
		$zone_id = hikashop::getZone('shipping');
		if($config->get('tax_zone_type','shipping')=='billing'){
			$tax_zone_id=hikashop::getZone('billing');
		}else{
			$tax_zone_id=$zone_id;
		}
		$discount_before_tax = (int)$config->get('discount_before_tax',0);
		$cart = null;
		$cart->products =& $this->get();
		$cart->cart_id = @$this->cart->cart_id;
		$cart->coupon = null;
		$cart->shipping = null;
		$cart->total = null;
		if(!empty($cart->products)){
			$ids = array_keys($cart->products);
			JArrayHelper::toInteger($ids);
			$query = 'SELECT * FROM '.hikashop::table('file').' WHERE file_ref_id IN ('.implode(',',$ids).') AND file_type = \'product\'';
			$database->setQuery($query);
			$images = $database->loadObjectList();
			if(!empty($images)){
				foreach($cart->products as $k => $row){
					$productClass->addImages($cart->products[$k],$images);
				}
			}
			foreach($cart->products as $k => $row){
				if($row->product_type=='variant'){
					foreach($cart->products as $k2 => $row2){
						if($row->product_parent_id==$row2->product_id){
							$cart->products[$k2]->variants[]=&$cart->products[$k];
							break;
						}
					}
				}
			}
			$query = 'SELECT a.*,b.* FROM '.hikashop::table('variant').' AS a LEFT JOIN '.hikashop::table('characteristic').' AS b ON a.variant_characteristic_id=b.characteristic_id WHERE a.variant_product_id IN ('.implode(',',$ids).') ORDER BY a.ordering,b.characteristic_value';
			$database->setQuery($query);
			$characteristics = $database->loadObjectList();
			if(!empty($characteristics)){
				foreach($cart->products as $key => $product){
					if($product->product_type!='variant'){
						$element =& $cart->products[$key];
						$product_id=$product->product_id;
						$mainCharacteristics = array();
						foreach($characteristics as $characteristic){
							if($product_id==$characteristic->variant_product_id){
								$mainCharacteristics[$product_id][$characteristic->characteristic_parent_id][$characteristic->characteristic_id]=$characteristic;
							}
							if(!empty($element->options)){
								foreach($element->options as $k => $option){
									if($option->product_id==$characteristic->variant_product_id){
										$mainCharacteristics[$option->product_id][$characteristic->characteristic_parent_id][$characteristic->characteristic_id]=$characteristic;
									}
								}
							}
						}
						if(!empty($element->variants)){
							$this->addCharacteristics($element,$mainCharacteristics,$characteristics);
						}
						if(!empty($element->options)){
							foreach($element->options as $k => $option){
								if(!empty($option->variants)){
									$this->addCharacteristics($element->options[$k],$mainCharacteristics,$characteristics);
								}
							}
						}
					}
				}
			}
			$currencyClass->getPrices($cart->products,$ids,$currency_id,$main_currency,$tax_zone_id,$discount_before_tax);
			foreach($cart->products as $k => $row){
				if(!empty($row->variants)){
					foreach($row->variants as $k2 => $variant){
						$productClass->checkVariant($cart->products[$k]->variants[$k2],$row);
					}
				}
			}
			$notUsable = array();
			foreach($cart->products as $k => $product){
				if(empty($product->product_id)){
					continue;
				}
				if(!empty($product->cart_product_quantity)){
					if(empty($product->product_published)){
						$notUsable[$k]=0;
						$app->enqueueMessage(JText::sprintf('PRODUCT_NOT_AVAILABLE',$product->product_name),'notice');
						continue;
					}
					if($product->product_quantity!=-1 && $product->product_quantity < $product->cart_product_quantity){
						$notUsable[$k]=0;
						$app->enqueueMessage(JText::sprintf('NOT_ENOUGH_STOCK_FOR_PRODUCT',$product->product_name),'notice');
						continue;
					}
					if($product->product_sale_start>time()){
						$notUsable[$k]=0;
						$app->enqueueMessage(JText::sprintf('PRODUCT_NOT_YET_ON_SALE',$product->product_name),'notice');
						continue;
					}
					if(!empty($product->product_sale_end) && $product->product_sale_end<time()){
						$notUsable[$k]=0;
						$app->enqueueMessage(JText::sprintf('PRODUCT_NOT_SOLD_ANYMORE',$product->product_name),'notice');
						continue;
					}
				}
			}
			if(!empty($notUsable)){
				$this->update($notUsable,1,0,'product');
				return $this->loadFullCart($addtionalInfos);
			}
			foreach($cart->products as $k => $row){
				$currencyClass->quantityPrices($cart->products[$k]->prices,@$row->cart_product_quantity,$main_currency);
			}
			$currencyClass->calculateTotal($cart->products,$cart->total,$currency_id);
			$cart->full_total=&$cart->total;
			if(hikashop::level(1) && empty($this->cart->cart_coupon)){
				$filters = array('discount_type=\'coupon\'','discount_published=1','discount_auto_load=1');
				hikashop::addACLFilters($filters,'discount_access');
				$query = 'SELECT * FROM '.hikashop::table('discount').' WHERE '.implode(' AND ',$filters).' ORDER BY discount_minimum_order DESC';
				$this->database->setQuery($query);
				$coupons = $this->database->loadObjectList();
				if(!empty($coupons)){
					$discount = hikashop::get('class.discount');
					$zoneClass = hikashop::get('class.zone');
					$zones = $zoneClass->getZoneParents($zone_id);
					foreach($coupons as $coupon){
						$result = $discount->check($coupon,$cart->total,$zones,$cart->products,false);
						if($result){
							$app->setUserState( HIKASHOP_COMPONENT.'.coupon_code','');
							$this->update($coupon->discount_code,1,0,'coupon',true);
							return $this->loadFullCart($addtionalInfos);
						}
					}
				}
			}
			if(!empty($this->cart->cart_coupon)){
				$discount=hikashop::get('class.discount');
				$zoneClass = hikashop::get('class.zone');
				$zones = $zoneClass->getZoneParents($zone_id);
				$cart->coupon = $discount->loadAndCheck($this->cart->cart_coupon,$cart->total,$zones,$cart->products,true);
				if(empty($cart->coupon)){
					$this->cart->cart_coupon='';
				}else{
					$cart->full_total=&$cart->coupon->total;
				}
			}
			$shipping_id = $app->getUserState( HIKASHOP_COMPONENT.'.shipping_id');
			if(!empty($shipping_id)){
				$cart->shipping = $app->getUserState( HIKASHOP_COMPONENT.'.shipping_data');
				if(!empty($cart->shipping)){
					$currencyClass = hikashop::get('class.currency');
					$shipping =& $cart->shipping;
					$shippings = array(&$shipping);
					$currencyClass->processShippings($shippings);
					$currencyClass->addShipping($cart->shipping,$cart->full_total);
					$cart->full_total=&$cart->shipping->total;
				}
			}
		}
		if($addtionalInfos){
			$app =& JFactory::getApplication();
			$shipping_address=$app->getUserState( HIKASHOP_COMPONENT.'.shipping_address',0);
			if(!empty($shipping_address)){
				$this->loadAddress($cart,$shipping_address);
			}
			$billing_address=$app->getUserState( HIKASHOP_COMPONENT.'.billing_address',0);
			if($billing_address==$shipping_address){
				$cart->billing_address =& $cart->shipping_address;
			}else{
				if(!empty($billing_address)){
					$this->loadAddress($cart,$billing_address,'parent','billing');
				}
			}
			$this->calculateWeightAndVolume($cart);
		}
		return $cart;
	}
	function addCharacteristics(&$element,&$mainCharacteristics,&$characteristics){
		$element->characteristics = $mainCharacteristics[$element->product_id][0];
		foreach($element->characteristics as $k => $characteristic){
			$element->characteristics[$k]->default=end($mainCharacteristics[$element->product_id][$k]);
		}
		if(!empty($element->variants)){
			foreach($characteristics as $characteristic){
				foreach($element->variants as $k => $variant){ 
					if($variant->product_id==$characteristic->variant_product_id){
						$element->variants[$k]->characteristics[$characteristic->characteristic_parent_id]=$characteristic;
						$element->characteristics[$characteristic->characteristic_parent_id]->values[$characteristic->characteristic_id]=$characteristic;
					}
				}
			}
		}
	}
	function loadAddress(&$order,$address,$loading_type='parent',$address_type='shipping'){
		$addressClass=hikashop::get('class.address');
		$name = $address_type.'_address';
		$order->$name=$addressClass->get($address);
		if(!empty($order->$name)){
			$array = array(&$order->$name);
			$addressClass->loadZone($array,$loading_type);
			if(!empty($addressClass->fields)){
				$order->fields =& $addressClass->fields;
			}
		}
	}
	function calculateWeightAndVolume(&$order){
		$order->volume = 0;
		$order->weight = 0;
		if(!empty($order->products)){
			$volumeClass=hikashop::get('helper.volume');
			$weightClass=hikashop::get('helper.weight');
			foreach($order->products as $k => $product){
				if(!empty($order->products[$k]->cart_product_quantity) && bccomp($product->product_length,0,5) && bccomp($product->product_width,0,5)&& bccomp($product->product_height,0,5)){
					$order->products[$k]->product_volume=$product->product_length*$product->product_width*$product->product_height;
					$order->products[$k]->product_total_volume=$order->products[$k]->product_volume*$order->products[$k]->cart_product_quantity;
					$order->products[$k]->product_total_volume_orig = $order->products[$k]->product_total_volume;
					$order->products[$k]->product_total_volume = $volumeClass->convert($order->products[$k]->product_total_volume,$product->product_dimension_unit);
					$order->volume+=$order->products[$k]->product_total_volume;
				}
			}
			foreach($order->products as $k => $product){
				if(!empty($order->products[$k]->cart_product_quantity) && bccomp($product->product_weight,0,5)){
					$order->products[$k]->product_weight_orig = $product->product_weight;
					$order->products[$k]->product_weight=$weightClass->convert($product->product_weight,$product->product_weight_unit);
					$order->weight+=$order->products[$k]->product_weight*$order->products[$k]->cart_product_quantity;
				}
			}
		}
	}
	function delete($id){
		$result = parent::delete($id);
		if($result){
			$app =& JFactory::getApplication();
			$app->setUserState( HIKASHOP_COMPONENT.'.cart_id', 0);
			$this->loadCart(0,true);
		}
		return $result;
	}
}
	
Return current item: HikaShop