Create a new cart not working

  • Posts: 190
  • Thank you received: 0
12 years 2 months ago #62016

Hi Nicolas,
after upgrading to 1.5.9, there is a "Create a new cart" icon in user control panel
If I click on it, page is refreshed, but without any change or action.

Any ideas ?
Thanks
Regards

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 2 months ago #62137

Thank you for the feedback. We'll look at that on monday and we'll publish a new version of HikaShop shortly which will fix that.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
12 years 2 months ago #62157

Hi codewarrior,

When you click on "Create a cart", it set the cart_id to 0 in session.
The page refresh, and a message is displayed "The new cartwill be displayed when products inside."

That mean that the cartwill really be created when a product is added to the cart.

Is the message "The new cart will be displayed when products inside." displayed when you click on "Create a cart" ?
Do you display the notice message in Joomla ?

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
11 years 6 months ago #103648

Hi

After Click On "Create a new cart" Button ...

Result Displayed Result 1-2 of 2 ... but there is no result in above table ...

Any solution .. ?

Last edit: 11 years 6 months ago by imranh.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 6 months ago #103661

Hi,

Do you have the latest version of HikaShop ?

I just tried on my end, and it display well Results 1 - 1 of 1

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
11 years 6 months ago #103667

Thankyou for reply

I have version 2.1.1 ...


Attachments:
Last edit: 11 years 6 months ago by imranh.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 6 months ago #103679

Hi,

Thanks to download the latest version from our website (2.1.3) install it over your current install and try again.

PS: Sorry, I was thinking that the problem was coming from the frontend, I have corrected the bug, thanks for the report.
To correct it on your end, you can edit the file "administrator/components/com_hiakshop/display/views/cart/view.html.php" and replace the function "listing()" by:

	function listing(){
		$this->setName();
		$config = hikashop_config();
		$app = JFactory::getApplication();
		$pageInfo = new stdClass();
		$pageInfo->filter = new stdClass();
		$pageInfo->filter->order = new stdClass();
		$pageInfo->limit = new stdClass();
		$pageInfo->search = $app->getUserStateFromRequest( $this->paramBase.".search", 'search', '', 'string' );
		$pageInfo->filter->order->value = $app->getUserStateFromRequest( $this->paramBase.".filter_order", 'filter_order',	'a.cart_modified','cmd' );
		$pageInfo->filter->order->dir	= $app->getUserStateFromRequest( $this->paramBase.".filter_order_Dir", 'filter_order_Dir',	'desc',	'word' );
		$pageInfo->limit->value = $app->getUserStateFromRequest( $this->paramBase.'.list_limit', 'limit', $app->getCfg('list_limit'), 'int' );
		$pageInfo->limit->start = $app->getUserStateFromRequest( $this->paramBase.'.limitstart', 'limitstart', 0, 'int' );

		$pageInfo->manageUser = hikashop_isAllowed($config->get('acl_user_manage','all'));
		$popup = (JRequest::getString('tmpl') === 'component');
		$database	= JFactory::getDBO();
		if(JRequest::getString('cart_type', 'cart') == 'cart')
			$filters = array('a.cart_type=\'cart\'');
		else
			$filters = array('a.cart_type=\'wishlist\'');
		$searchMap = array('a.cart_id','a.user_id','a.cart_name','a.cart_coupon','a.cart_type');
		if(!empty($pageInfo->search)){
			$searchVal = '\'%'.hikashop_getEscaped(JString::strtolower( $pageInfo->search ),true).'%\'';
			$filters[] =  implode(" LIKE $searchVal OR ",$searchMap)." LIKE $searchVal";
		}
		$groupBy = 'GROUP BY a.cart_id';
		$order = '';
		if(!empty($pageInfo->filter->order->value)){
			$order = ' ORDER BY '.$pageInfo->filter->order->value.' '.$pageInfo->filter->order->dir;
		}
		if(!empty($filters)){
			$filters = ' WHERE '. implode(' AND ',$filters);
		}else{
			$filters = '';
		}
	// 2 requests > 1 for the carts > 1 for the products
		$from = 'FROM '.hikashop_table('cart').' AS a';
		$cartProduct = 'JOIN '.hikashop_table('cart_product').' AS b ON a.cart_id=b.cart_id';
		$query = $from.' '.$cartProduct.' '.$filters.' '.$groupBy.' '.$order;
		$database->setQuery('SELECT a.*, b.* '.$query,(int)$pageInfo->limit->start,(int)$pageInfo->limit->value);
		$rows = $database->loadObjectList();
		if(!empty($pageInfo->search)){
			$rows = hikashop_search($pageInfo->search,$rows,'cart_id');
		}
		$database->setQuery('SELECT COUNT(*) '.$from.' '.$cartProduct.' '.$filters.' '.$groupBy);
		$pageInfo->elements = new stdClass();
		$pageInfo->elements->total = $database->loadResult();
		$pageInfo->elements->page = count($rows);
		$currencyClass = hikashop_get('class.currency');
		$this->assignRef('currencyHelper',$currencyClass);


		// EO Filters & Pagination

		$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();
		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);

	// New filters to have only items from selected carts
		$cids = array();
		foreach($rows as $row){
			if($row->cart_id != null)
				$cids[] = $row->cart_id;
		}
		if(!empty($cids))
		$filters = array('a.cart_id IN('.implode(",",$cids).')');
		$order = '';
		if(!empty($pageInfo->filter->order->value)){
			$order = ' ORDER BY cart_id ASC';
		}
	// 2nd request to have the products caracteristics
		$products = null;
		if(!empty($cids)){
			$product = ' LEFT JOIN '.hikashop_table('product').' AS b ON a.product_id=b.product_id';
			$query = 'FROM '.hikashop_table('cart_product').' AS a '.$product.' WHERE ('.implode(') AND (',$filters).') '.$order;
			$database->setQuery('SELECT a.*,b.* '.$query);
			$products = $database->loadObjectList();
		}
		if(!empty($products)){
			$ids = array();
			foreach($products as $row){
				$ids[] = $row->product_id;
			}
			$row_1 = 0;
			foreach($products as $k => $row){
				$currencyClass->getPrices($row,$ids,$currency_id,$main_currency,$zone_id,$discount_before_tax);
				if(!isset($row->prices[0]) && isset($row_1->prices[0])){
					$row->prices[0] = $row_1->prices[0];
				}
				$products[$k]->hide = 0;
				if($row->product_type == 'variant'){
					$products[--$k]->hide = 1;
				}
				$row_1 = $row;
			}
			$currentId = 0;
			$values = array();
			$currency = hikashop_getCurrency();
			foreach($products as $product){
				if(isset($product->cart_id)){
					if($product->cart_id != $currentId){
						$price = 0;
						$quantity = 0;
						$currentId = $product->cart_id;
						if(isset($product->prices[0]))
							$currency = $product->prices[0]->price_currency_id;
					}
					if(isset($product->prices[0])){
						$price += $product->cart_product_quantity * $product->prices[0]->price_value;
						$quantity += $product->cart_product_quantity;
					}
					if(!isset($values[$currentId])) $values[$currentId] = new stdClass();
					$values[$currentId]->price = $price;
					$values[$currentId]->quantity = $quantity;
					$values[$currentId]->currency = $currency;
				}
			}
		}
		foreach($rows as $k => $row){
			if($values[$row->cart_id] != null){
				$rows[$k]->price = $values[$row->cart_id]->price;
				$rows[$k]->quantity = $values[$row->cart_id]->quantity;
				$rows[$k]->currency = $values[$row->cart_id]->currency;
			}
		}
		$cart=hikashop_get('helper.cart');
		$this->assignRef('cart',$cart);
		$this->assignRef('carts',$rows);
		$this->assignRef('popup',$popup);
		$pageInfo->elements->total = count($rows);
		$pagination = hikashop_get('helper.pagination', $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);
		$pagination->hikaSuffix = '';
		$this->assignRef('pagination',$pagination);
		$this->assignRef('pageInfo',$pageInfo);
		hikashop_setTitle(JText::_($this->nameListing),$this->icon,$this->ctrl);

		$config =& hikashop_config();
		$manage = hikashop_isAllowed($config->get('acl_wishlist_manage','all'));
		$this->assignRef('manage',$manage);
		$this->toolbar = array(
			array('name'=>'addNew','display'=>$manage),
			array('name'=>'editList','display'=>$manage),
			array('name'=>'deleteList','display'=>hikashop_isAllowed($config->get('acl_wishlist_delete','all'))),
			'|',
			array('name' => 'pophelp', 'target' => $this->ctrl.'-listing'),
			'dashboard'
		);
	}

Last edit: 11 years 6 months ago by Xavier.
The following user(s) said Thank You: imranh

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
11 years 6 months ago #103696

Thankyou sir,

same bug at frontend ....

Attachments:
Last edit: 11 years 6 months ago by imranh.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 6 months ago #103795

Hi,

This time thanks to replace the function "showcarts()" in "components/com_hikashop/views/cart/view.html.php" by:

	function showcarts(){
		$app = JFactory::getApplication();
		$menus	= $app->getMenu();
		$menu	= $menus->getActive();
		if(empty($menu)){
			if(!empty($Itemid)){
				$menus->setActive($Itemid);
				$menu = $menus->getItem($Itemid);
			}
		}
		if(empty($cart_type)){
			if (is_object( $menu->params )) {
				$cart_type = $menu->params->get('cart_type');
			}
			if(!empty($cart_type)){
				JRequest::setVar('cart_type',$cart_type);
			}else{
				$cart_type = JRequest::getString('cart_type','cart');
			}
		}

		// Filters & Pagination
		$pageInfo = new stdClass();
		$pageInfo->filter = new stdClass();
		$pageInfo->filter->order = new stdClass();
		$pageInfo->limit = new stdClass();
		$pageInfo->filter->order->value = $app->getUserStateFromRequest( $this->paramBase.".filter_order", 'filter_order',	'a.cart_id','cmd' );
		$pageInfo->filter->order->dir	= $app->getUserStateFromRequest( $this->paramBase.".filter_order_Dir", 'filter_order_Dir',	'desc',	'word' );
		$pageInfo->search = $app->getUserStateFromRequest( $this->paramBase.".search", 'search', '', 'string' );
		$pageInfo->search = JString::strtolower( $pageInfo->search );
		$pageInfo->limit->start = $app->getUserStateFromRequest( $this->paramBase.'.limitstart', 'limitstart', 0, 'int' );
		$oldValue = $app->getUserState($this->paramBase.'.list_limit');
		if(empty($oldValue)){
			$oldValue =$app->getCfg('list_limit');
		}
		$pageInfo->limit->value = $app->getUserStateFromRequest( $this->paramBase.'.list_limit', 'limit', $app->getCfg('list_limit'), 'int' );
		if($oldValue!=$pageInfo->limit->value){
			$pageInfo->limit->start = 0;
			$app->setUserState($this->paramBase.'.limitstart',0);
		}

		$database = JFactory::getDBO();
		$searchMap = array('a.cart_id','a.cart_name','a.cart_type');
		$user = hikashop_loadUser(true);
		if(isset($user->user_cms_id))
			$user->id = $user->user_cms_id;
		else {
			if(empty($user)) $user = new stdClass();
			$user->id = 0 ;
		}
		$session = JFactory::getSession();
		if($session->getId()){
			$user->session = $session->getId();
		}else{
			$user->session = '';
		}
		if(hikashop_loadUser() == null){
			$filters = array('a.session_id='.$database->Quote($user->session).' AND a.cart_type ='.$database->quote($cart_type));
		}else{
			$filters = array('(a.user_id='.(int)$user->id.' OR a.session_id='.$database->Quote($user->session).') AND a.cart_type ='.$database->quote($cart_type));
		}
		$groupBy = 'GROUP BY a.cart_id';
		$order = '';
		if(!empty($pageInfo->filter->order->value)){
			$order = 'ORDER BY a.cart_id ASC';
		}
		if(!empty($pageInfo->search)){
			$searchVal = '\'%'.hikashop_getEscaped(JString::strtolower( $pageInfo->search ),true).'%\'';
			$filter = implode(" LIKE $searchVal OR ",$searchMap)." LIKE $searchVal";
			$filters[] =  $filter;
		}
	// 2 requests > 1 for the carts > 1 for the products
		$from = 'FROM '.hikashop_table('cart').' AS a';
		$cartProduct = 'LEFT JOIN '.hikashop_table('cart_product').' AS b ON a.cart_id=b.cart_id';
		$where = 'WHERE ('.implode(') AND (',$filters).')';
		$query = $from.' '.$where.' '.$groupBy.' '.$order; //'.$cartProduct.'
		$database->setQuery('SELECT a.* '.$query,(int)$pageInfo->limit->start,(int)$pageInfo->limit->value);
		$rows = $database->loadObjectList();
		$database->setQuery('SELECT COUNT(*) '.$from.' '.$where);
		$currencyClass = hikashop_get('class.currency');
		$this->assignRef('currencyHelper',$currencyClass);

		// EO Filters & Pagination

		$module = hikashop_get('helper.module');
		$module->initialize($this);
		$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();
		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);

	// New filters to have only items from selected carts
		$cids = array();
		foreach($rows as $row){
			if($row->cart_id != null)
				$cids[] = $row->cart_id;
		}
		$filters = '';
		$filters = array('a.cart_id IN('.implode(",",$cids).')');
		$order = '';
		if(!empty($pageInfo->filter->order->value)){
			$order = ' ORDER BY cart_id ASC';
		}

	// 2nd request to have the products caracteristics
		$product = ' LEFT JOIN '.hikashop_table('product').' AS b ON a.product_id=b.product_id';
		$query = 'FROM '.hikashop_table('cart_product').' AS a '.$product.' WHERE ('.implode(') AND (',$filters).') '.$order;
		$database->setQuery('SELECT a.*,b.* '.$query);
		if(!empty($cids)){
			$products = $database->loadObjectList();

			$ids = array();
			foreach($products as $row){
				$ids[] = $row->product_id;
			}
			$row_1 = 0;
			foreach($products as $k => $row){
				$currencyClass->getPrices($row,$ids,$currency_id,$main_currency,$zone_id,$discount_before_tax);

				// If price is null > Variant > get the price of the main product
				if(!isset($row->prices[0]->price_value)){
					if(isset($row_1->prices[0]))
						$row->prices[0] = $row_1->prices[0];
				}
				//If row_type = variant, the oldest is a main > hide the main
				$products[$k]->hide = 0;
				if($row->product_type == 'variant'){
					$products[--$k]->hide = 1;
				}
				$row_1 = $row;
			}

			//Calcul the price of each carts & quantity of product in.
			$currentId = 0;
			$values = null;
			$price = 0;
			$price_with_tax = 0;
			$quantity = 0;
			$currency = hikashop_getCurrency();
			foreach($products as $product){
				if(isset($product->cart_id)){
					if($product->cart_id != $currentId){
						$price = 0;
						$price_with_tax = 0;
						$quantity = 0;
						$currentId = $product->cart_id;
						if(isset($product->prices[0]->price_currency_id))
							$currency = $product->prices[0]->price_currency_id;
					}

					if(isset($product->prices[0])){
						$price += $product->cart_product_quantity * $product->prices[0]->price_value;
					}
					if(isset($product->prices[0]->price_value_with_tax)){
						$price_with_tax += $product->cart_product_quantity * $product->prices[0]->price_value_with_tax;
					}
					if(!isset($product->prices[0]->price_value)){
						$variant = new stdClass();
						$variant->product_parent_id = $product->product_parent_id;
						$variant->quantity = $product->cart_product_quantity;
					}
					if(isset($variant) && isset($product->prices[0]) && $product->product_id == $variant->product_parent_id){
						$price += $variant->quantity * $product->prices[0]->price_value;
						$price_with_tax += $variant->quantity * $product->prices[0]->price_value_with_tax;
					}
					$quantity += $product->cart_product_quantity;
					if(!isset($values[$currentId])) $values[$currentId] = new stdClass();
					$values[$currentId]->price = $price;
					$values[$currentId]->price_with_tax = isset($price_with_tax)?$price_with_tax:$price;
					$values[$currentId]->quantity = $quantity;
					$values[$currentId]->currency = $currency;
				}
			}
			// add the values to the carts
			$totalCart = 0;
			foreach($rows as $k => $row){
				if(isset($values[$row->cart_id]) && $values[$row->cart_id] != null){
					$rows[$k]->price = $values[$row->cart_id]->price;
					$rows[$k]->price_with_tax = $values[$row->cart_id]->price_with_tax;
					$rows[$k]->quantity = $values[$row->cart_id]->quantity;
					$rows[$k]->currency = $values[$row->cart_id]->currency;
					$totalCart++;
				}else{
					unset($rows[$k]);
				}
			}
		}

		$pageInfo->elements = new stdClass();
		$pageInfo->elements->total = count($rows);
		if(!empty($pageInfo->search)){
			$rows = hikashop_search($pageInfo->search,$rows,'cart_id');
		}
		$pageInfo->elements->page = count($rows);
		if(!$pageInfo->elements->page){
			if(hikashop_loadUser()!= null){
				$app = JFactory::getApplication();
				if($cart_type == 'cart')
					$app->enqueueMessage(JText::_('HIKA_NO_CARTS_FOUND'));
				else
					$app->enqueueMessage(JText::_('HIKA_NO_WISHLISTS_FOUND'));
			}
		}
		jimport('joomla.html.pagination');
		$pagination = hikashop_get('helper.pagination', $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);
		$pagination->hikaSuffix = '';
		$this->assignRef('pagination',$pagination);
		$this->assignRef('pageInfo',$pageInfo);

		$cart=hikashop_get('helper.cart');
		$this->assignRef('cart',$cart);
		$this->assignRef('config',$config);
		$this->assignRef('carts',$rows);
	}

And thanks again for the report.

The following user(s) said Thank You: imranh

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
11 years 6 months ago #103918

I thing more ..





this notification still appears while i added products ...

Attachments:
Last edit: 11 years 6 months ago by imranh.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 6 months ago #104043

Hi,

You are checking that by pressing "F5" ?
If it is, that's because the url redirect to the newCart action, so refreshing go to the same page. And create again a new cart.

I will improve this functionality, I have added it on the todo list.

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
11 years 6 months ago #104045

Hi,

Did all possible actions (F5, create new cart) ..

Please Log in or Create an account to join the conversation.

Time to create page: 0.115 seconds
Powered by Kunena Forum