cart does not update

  • Posts: 62
  • Thank you received: 1
9 years 2 months ago #214467

-- url of the page with the problem -- : flatize.fabulosa.ch
-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.4
-- PHP version -- : 5.4.44

Hi

My problem is maybe cache related. I have jotcache and excluded com_hikashop but it doesnt work. The cart wont update after pressing empty cart button. The product seems to be still in the cart.

I have seen that in new Version of hikashop the cache is cleaned after updating the cart. I have custom code in cart of view checkout with hikashop 2.3.2 so this file was not updated. Can I insert the missing code manually?

Regards
florcar

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

  • Posts: 82909
  • Thank you received: 13379
  • MODERATOR
9 years 2 months ago #214477

Hi,

I don't see that this is the issue.
The cart clearing button has not been made to support the Joomla caching yet. It will be in the next version of HikaShop.
In the mean time, you can edit the file components/com_hikashop/controllers/cart.php and add the code:

if(HIKASHOP_J30){
			$plugin = JPluginHelper::getPlugin('system', 'cache');
			$params = new JRegistry(@$plugin->params);

			$options = array(
				'defaultgroup'	=> 'page',
				'browsercache'	=> $params->get('browsercache', false),
				'caching'		=> false,
			);

			$cache		= JCache::getInstance('page', $options);
			//$cache_key	= JUri::getInstance()->toString();
			$cache->clean();
		}
after the line:
public function cleancart() {

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

  • Posts: 62
  • Thank you received: 1
9 years 2 months ago #214585

Hi Nicolas
Ah ok I see. But when deleting single item in cart the cache is cleaned?
About the code. I dont see a function like cleancart. Is it maybe:

function delete(){ //delete a cart with the id given
?
Or is it in the root administrator/components/com_hikashop/controllers/cart.php ?
Best regards

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

  • Posts: 82909
  • Thank you received: 13379
  • MODERATOR
9 years 2 months ago #214606

Hi,

No, it's the function cleancart, not delete.
You're probably looking at the file administrator/components/com_hikashop/controllers/cart.php while I told you to look instead at the file components/com_hikashop/controllers/cart.php

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

  • Posts: 62
  • Thank you received: 1
9 years 2 months ago #214662

Hi
I was looking at this file first. But there is no such function. Really, see attached file.

Attachments:

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

  • Posts: 82909
  • Thank you received: 13379
  • MODERATOR
9 years 2 months ago #214850

Hi,

My bad, it's the file components/com_hikashop/controllers/product.php

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

  • Posts: 62
  • Thank you received: 1
9 years 2 months ago #214855

Hi
Ok but the function is not public. Do I have to change that?

function cleancart(){
Edit:
Tried to insert the code but it didnt work

Last edit: 9 years 2 months ago by florcar. Reason: Tried the code

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

  • Posts: 82909
  • Thank you received: 13379
  • MODERATOR
9 years 2 months ago #214866

Hi,

What do you mean by "it didn't work" ? You got an error ? It doesn't change anything ? What code do you have now ? Could you do a screenshot ?

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

  • Posts: 62
  • Thank you received: 1
9 years 2 months ago #214911

Hi

I inserted the code as you posted it right under function cleancart(){
I didnt get an error but it did not change anything.
Here is what I tryed:

function cleancart(){
		if(HIKASHOP_J30){
			$plugin = JPluginHelper::getPlugin('system', 'cache');
			$params = new JRegistry(@$plugin->params);

			$options = array(
				'defaultgroup'	=> 'page',
				'browsercache'	=> $params->get('browsercache', false),
				'caching'		=> false,
			);

			$cache		= JCache::getInstance('page', $options);
			//$cache_key	= JUri::getInstance()->toString();
			$cache->clean();
		}
		$class = hikashop_get('class.cart');
		if($class->hasCart()){
			$class->delete($class->cart->cart_id);
		}

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

  • Posts: 13201
  • Thank you received: 2322
9 years 2 months ago #214949

Hi,

Please try to replace the content of the function cleancart() by:

	public function cleancart() {
		$cartClass = hikashop_get('class.cart');
		if($cartClass->hasCart())
			$cartClass->delete($cartClass->cart->cart_id);

		$url = JRequest::getVar('return_url','');
		if(empty($url)) {
			$url = JRequest::getVar('url','');
			$url = urldecode($url);
		} else {
			$url = base64_decode(urldecode($url));
		}

		if(HIKASHOP_J30){
			$plugin = JPluginHelper::getPlugin('system', 'cache');
			$params = new JRegistry(@$plugin->params);

			$options = array(
				'defaultgroup'	=> 'page',
				'browsercache'	=> $params->get('browsercache', false),
				'caching'		=> false,
			);

			$cache		= JCache::getInstance('page', $options);
			//$cache_key	= JUri::getInstance()->toString();
			$cache->clean();
		}

		if(empty($url)) {
			echo '<html><head><script type="text/javascript">history.go(-1);</script></head><body></body></html>';
			exit;
		}

		if(strpos($url, 'tmpl=component') !== false || strpos($url, 'tmpl-component') !== false) {
			if(!empty($_SERVER['HTTP_REFERER'])) {
				$app = JFactory::getApplication();
				$app->redirect($_SERVER['HTTP_REFERER']);
			} else {
				echo '<html><head><script type="text/javascript">history.back();</script></head><body></body></html>';
				exit;
			}
		}
		if(hikashop_disallowUrlRedirect($url))
			return false;
		$this->setRedirect($url);
	}

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

  • Posts: 62
  • Thank you received: 1
9 years 2 months ago #215047

Hi Xavier

Thanks for the code.
I replaced it and tried but unfortunately it doesnt work. :dry:
Deleting each product seperately worked allready before but the «WARENKORB LEEREN» («clean cart») doesent delete the items in cart.
I now disabled the button clean cart and think the customers can live with deleting each product seperately :)
As Nicolas mentioned is this modification part of a future update. Maybe it will work then :)

Thanks for the support and best regards

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

Time to create page: 0.091 seconds
Powered by Kunena Forum