alan4573 Posted May 3, 2010 Share Posted May 3, 2010 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.2Prestashop Version 1.2.5.0 - 0.778s ThanksAlan Link to comment Share on other sites More sharing options...
alan4573 Posted May 4, 2010 Author Share Posted May 4, 2010 No-one?I'm sure I'm not the only person who wants this.Guess I'll have to do it myself then. Link to comment Share on other sites More sharing options...
shacker Posted May 4, 2010 Share Posted May 4, 2010 No-one?I'm sure I'm not the only person who wants this.Guess I'll have to do it myself then. you can try disable the ajax feature in the module configuration of the cart block Link to comment Share on other sites More sharing options...
alan4573 Posted May 4, 2010 Author Share Posted May 4, 2010 Hi,Thanks for the reply.Unfortunately, disabling Ajax would make it even worse because the cart would be permanently expanded without having the option of collapsing it manually. Link to comment Share on other sites More sharing options...
Burhan BVK Posted May 4, 2010 Share Posted May 4, 2010 Try to put this in the header.tpl file: <script type="text/javascript" > $(document).ready(function(){ldelim} $("#block_cart_collapse").click(); {rdelim}); </script> Link to comment Share on other sites More sharing options...
alan4573 Posted May 4, 2010 Author Share Posted May 4, 2010 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 More sharing options...
alan4573 Posted May 6, 2010 Author Share Posted May 6, 2010 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 More sharing options...
rocky Posted May 7, 2010 Share Posted May 7, 2010 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 More sharing options...
babyewok Posted July 15, 2010 Share Posted July 15, 2010 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 More sharing options...
system68 Posted October 20, 2010 Share Posted October 20, 2010 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.jsand 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 More sharing options...
DATO Posted June 12, 2011 Share Posted June 12, 2011 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.5because 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 More sharing options...
ErikSebastia2 Posted December 30, 2011 Share Posted December 30, 2011 How I can do this on the new version of prestashop? Thanks Link to comment Share on other sites More sharing options...
ErikSebastia2 Posted January 2, 2012 Share Posted January 2, 2012 UP! Link to comment Share on other sites More sharing options...
ErikSebastia2 Posted January 17, 2012 Share Posted January 17, 2012 How I can do this on prestashop 1.4.X? Thanks Link to comment Share on other sites More sharing options...
gfdesign Posted January 6, 2013 Share Posted January 6, 2013 (edited) 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 January 6, 2013 by gfdesign (see edit history) Link to comment Share on other sites More sharing options...
mixmax18 Posted January 12, 2013 Share Posted January 12, 2013 EDIT: I got it, I had to disable on ajax-cart.js this line: // var cart_block = new HoverWatcher('#cart_block'); nice thanks dude Link to comment Share on other sites More sharing options...
alpe09ag Posted February 13, 2013 Share Posted February 13, 2013 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 More sharing options...
turdi Posted April 6, 2013 Share Posted April 6, 2013 (edited) 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 April 6, 2013 by turdi (see edit history) Link to comment Share on other sites More sharing options...
seog Posted April 14, 2013 Share Posted April 14, 2013 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 More sharing options...
oscarhh Posted June 7, 2013 Share Posted June 7, 2013 simply replacing ajaxCart.refresh(); for ajaxCart.collapse(); in ajax-cart.js (under //when document is loaded...) will keep the cart collpased by default Link to comment Share on other sites More sharing options...
Recommended Posts