function cart(){
$module = hikashop_get('helper.module');
$module->initialize($this);
if(!HIKASHOP_PHP5) {
$app =& JFactory::getApplication();
$database =& JFactory::getDBO();
$config =& hikashop_config();
} else {
$app = JFactory::getApplication();
$database = JFactory::getDBO();
$config = hikashop_config();
}
$currencyClass = hikashop_get('class.currency');
$class = hikashop_get('class.cart');
$productClass = hikashop_get('class.product');
$main_currency = (int)$config->get('main_currency',1);
$currency_id = hikashop_getCurrency();
//$currency_id = $app->getUserStateFromRequest( HIKASHOP_COMPONENT.'.currency_id', 'currency_id', $main_currency, 'int' );
if($config->get('tax_zone_type','shipping')=='billing'){
$zone_id = hikashop_getZone('billing');
}else{
$zone_id = hikashop_getZone('shipping');
}
$discount_before_tax = (int)$config->get('discount_before_tax',0);
$cart_type = $this->params->get('cart_type','cart');
$cart_id =$app->getUserState( HIKASHOP_COMPONENT.'.'.$cart_type.'_id', 0, 'int' );
//$rows = $class->get($cart_id,false,$cart_type);
$full = $class->loadFullCart(true);
$rows = $full->products;
$total = new stdClass();
/*
if(!empty($rows)){
//add variants inside main products as reference for tax calculus
$variants = false;
$ids = array();
foreach($rows as $k => $row){
$ids[]=$row->product_id;
if($row->product_type=='variant'){
$variants = true;
foreach($rows as $k2 => $row2){
if($row->product_parent_id==$row2->product_id){
$rows[$k2]->variants[]=&$rows[$k];
// break;
}
}
}
}
if($variants){
$this->selected_variant_id = 0;
//add the characteristics infos
$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 ASC,b.characteristic_value ASC';
$database->setQuery($query);
$characteristics = $database->loadObjectList();
if(!empty($characteristics)){
foreach($rows as $k => $row){
$element =& $rows[$k];
$product_id=$row->product_id;
if($row->product_type=='variant'){
continue;
}
$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 => $optionElement){
if($optionElement->product_id==$characteristic->variant_product_id){
$mainCharacteristics[$optionElement->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 => $optionElement){
if(!empty($optionElement->variants)){
$this->addCharacteristics($element->options[$k],$mainCharacteristics,$characteristics);
}
}
}
}
}
}
//calculate prices
$product_quantities = array();
foreach($rows as $row){
if(empty($product_quantities[$row->product_id])){
$product_quantities[$row->product_id] = (int)@$row->cart_product_quantity;
}else{
$product_quantities[$row->product_id]+=(int)@$row->cart_product_quantity;
}
if(empty($product_quantities[$row->product_parent_id])){
$product_quantities[$row->product_parent_id] = (int)@$row->cart_product_quantity;
}else{
$product_quantities[$row->product_parent_id] += (int)@$row->cart_product_quantity;
}
}
foreach($rows as $k => $row){
$rows[$k]->cart_product_total_quantity = $product_quantities[$row->product_id];
if($row->product_parent_id){
$rows[$k]->cart_product_total_variants_quantity = $product_quantities[$row->product_parent_id];
}else{
$rows[$k]->cart_product_total_variants_quantity = $rows[$k]->cart_product_total_quantity;
}
}
//calculate prices
$currencyClass->getPrices($rows,$ids,$currency_id,$main_currency,$zone_id,$discount_before_tax);
foreach($rows as $k => $row){
if(!empty($row->variants)){
foreach($row->variants as $k2 => $variant){
$productClass->checkVariant($rows[$k]->variants[$k2],$row);
}
}
}
foreach($rows as $k => $row){
$currencyClass->calculateProductPriceForQuantity($rows[$k]);
//If row_type = variant, the oldest is a main > hide the main
$rows[$k]->hide = 0;
if($row->product_type == 'variant'){
$rows[--$k]->hide = 1;
}
}
$total=new stdClass();
$currencyClass->calculateTotal($rows,$total,$currency_id);
}
*/
$this->assignRef('total',$total);
$this->assignRef('rows',$rows);
$this->assignRef('config',$config);
$cart=hikashop_get('helper.cart');
$this->assignRef('cart',$cart);
$this->assignRef('currencyHelper',$currencyClass);
$cart->cartCount(true);
$url = $this->init(true);
$this->params->set('url',$url);
ob_start();
$cart->getJS($url,false);
$notice_html = ob_get_clean();
$this->assignRef('notice_html',$notice_html);
if(hikashop_level(2)){
$null=null;
$fieldsClass=hikashop_get('class.field');
$itemFields = $fieldsClass->getFields('frontcomp',$null,'item','checkout&task=state');
$this->assignRef('itemFields',$itemFields);
$this->assignRef('fieldsClass',$fieldsClass);
}
//$this->addJS();
}