Jump to content

Cart Module always expanded


Recommended Posts

Hi,

Can anyone explain how I can make the cart module default to the collapsed position and stay collapsed until something is added to the cart.

No matter what I try to edit, the module always defaults to the expanded position and stays expanded - the only way I can can close it is to manually click on the close icon - this is not ideal for shoppers.

I have the Cart Ajax activated and my version of the module is Cart Block v1.2
Prestashop Version 1.2.5.0 - 0.778s

Thanks

Alan

Link to comment
Share on other sites

Hi,

Many thanks for the reply, but this seems to achieve the same as I have managed so far - that is after clearing cache/cookies etc, the page loads and the cart briefly collapses only to expand again and stay expanded.

This is driving me nuts - it should be so simple.

Thanks again for taking the time to respond.

Link to comment
Share on other sites

Bump - This is ridiculous.

Nothing .... and I mean nothing I try is working.

Something deep in the core code must be forcing the cart to expand and stay expanded.
Surely someone has managed to achieve this???

Cheers

Link to comment
Share on other sites

The expand/collapse status of the cart is stored in Prestashop's cookie. Your cookie must have 'expanded' in it, which is why you can't get it to stay collapsed. You can override the cookie and make it always collapsed by default by changing lines 53-54 of modules/blockcart/blockcart.php (in Prestashop v1.2.5) from:

if(isset($cookie->ajax_blockcart_display))
   $smarty->assign('colapseExpandStatus', $cookie->ajax_blockcart_display);



to:

// if(isset($cookie->ajax_blockcart_display))
//    $smarty->assign('colapseExpandStatus', $cookie->ajax_blockcart_display);
$smarty->assign('colapseExpandStatus', 'collapsed');



Also, the cart is expanded every time the cart is updated. You can stop this happening by commenting out line 487 of modules/blockcart/ajax-cart.js (in Prestashop v1.2.5):

ajaxCart.expand();



But this won't solve your problem, since you want the cart to expand when something is added to the cart. It is the following code on line 103 of the refresh function in ajax-cart.js (in Prestashop v1.2.5) that is causing the cart to expand before anything is added to the cart:

ajaxCart.updateCart(jsonData)



You can comment out this line to prevent the cart expanding before anything is added to the cart, but then this means that the cart won't refresh when you click the back button on the browser. Would that be acceptable for you?

Link to comment
Share on other sites

  • 2 months later...

Hi, Your first suggestion doesn't work for me - even though I set it to be ignore the cookie, it still keeps opening.

The second option is OK, but would I'd rather it refrehed on hitting the back button.

The final solution I could live with, except that it only shows the word 'product' when the cart is closed rather than including the number of products and cart total as it should. Any ideas why that should be happening?

Link to comment
Share on other sites

  • 3 months later...

I realize this is an old post but had a similar problem. Maybe it's fixed in the new version yet I'm using Ion Cannon's Express Checkout which overwrote the original blockcart module. Anyhow, to get the expanding and collapsing of the cart module to function with being collapsed on empty and expanded with items, modify ajax-cart.js

and change

ajaxCart.expand();



to:

if($('#cart_block #cart_block_list dl.products').length > 0) {
   ajaxCart.expand();
}




and on line ~533 (the beginning of the else in the updateCartEverywhere function) add:

ajaxCart.collapse();

Link to comment
Share on other sites

  • 7 months later...

i would like to keep my cart to be collapsed always


// if(isset($cookie->ajax_blockcart_display))
// $smarty->assign(‘colapseExpandStatus’, $cookie->ajax_blockcart_display); $smarty->assign(‘colapseExpandStatus’, ‘collapsed’);

i also do it. but don’t know why it don’t made effect. i use 1.4.2.5

because i have my design, and i move cart to top. so i just would like to know any other key change for always collapsed?

thx.

Link to comment
Share on other sites

  • 6 months later...
  • 3 weeks later...
  • 11 months later...

I'm looking for the same. I would like to have expanded my cart always. It's due to my design.

Anybody can give me any idea?

I'm using PS 1.5.3

Thanks

 

EDIT:

I got it, I had to disable on ajax-cart.js this line:

// var cart_block = new HoverWatcher('#cart_block');

Edited by gfdesign (see edit history)
Link to comment
Share on other sites

  • 1 month later...

The expand/collapse status of the cart is stored in Prestashop's cookie. Your cookie must have 'expanded' in it, which is why you can't get it to stay collapsed. You can override the cookie and make it always collapsed by default by changing lines 53-54 of modules/blockcart/blockcart.php (in Prestashop v1.2.5) from:

 

if(isset($cookie->ajax_blockcart_display))
$smarty->assign('colapseExpandStatus', $cookie->ajax_blockcart_display);

 

to:

 

// if(isset($cookie->ajax_blockcart_display))
//	$smarty->assign('colapseExpandStatus', $cookie->ajax_blockcart_display);
$smarty->assign('colapseExpandStatus', 'collapsed');

 

Also, the cart is expanded every time the cart is updated. You can stop this happening by commenting out line 487 of modules/blockcart/ajax-cart.js (in Prestashop v1.2.5):

 

ajaxCart.expand();

 

But this won't solve your problem, since you want the cart to expand when something is added to the cart. It is the following code on line 103 of the refresh function in ajax-cart.js (in Prestashop v1.2.5) that is causing the cart to expand before anything is added to the cart:

 

ajaxCart.updateCart(jsonData)

 

You can comment out this line to prevent the cart expanding before anything is added to the cart, but then this means that the cart won't refresh when you click the back button on the browser. Would that be acceptable for you?

 

Thanks for your help!

 

I know that this might be inappropriate to post here, but I also need the Block Layered Module to be collapsed by default. Please help me out!? - I tried to edit the cody myself, but with no results!

 

Any help will be highly appreciated!

Link to comment
Share on other sites

  • 1 month later...

I'm looking for the same. I would like to have expanded my cart always. It's due to my design.

Anybody can give me any idea?

I'm using PS 1.5.3

Thanks

 

EDIT:

I got it, I had to disable on ajax-cart.js this line:

// var cart_block = new HoverWatcher('#cart_block');

 

This worked nice, but the other problem is that when you remove the items from cart it dissapears, any fix?

 

I suppose the fix is here, but I'm a total beginner in JavaScript

 

    // If the cart is now empty, show the 'no product in the cart' message and close detail
    if($('#cart_block dl.products dt').length == 0)
    {
	 $("#cart_block").stop(true, true).slideUp(200);
	 $('#cart_block_no_products:hidden').slideDown(450);
	 $('#cart_block dl.products').remove();
    }
   });

Edited by turdi (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

This worked nice, but the other problem is that when you remove the items from cart it dissapears, any fix?

 

I suppose the fix is here, but I'm a total beginner in JavaScript

 

	// If the cart is now empty, show the 'no product in the cart' message and close detail
	if($('#cart_block dl.products dt').length == 0)
	{
	 $("#cart_block").stop(true, true).slideUp(200);
	 $('#cart_block_no_products:hidden').slideDown(450);
	 $('#cart_block dl.products').remove();
	}
   });

 

In prestashop 1.5.4 same it occur to me. I replaced all the words "collpase" by "expanded" in ajax-car.js but this don´t work

Does anyone know what code is necessary to modify?

Link to comment
Share on other sites

  • 1 month later...
×
×
  • Create New...