Jump to content

Hide cart block, if empty (ajax)


Recommended Posts

How can the cart block be hidden when there are no items in the cart? The cart should also be invisible as soon as all products are removed from the cart through the "remove_link" (line 86 in blockcart.tpl). I am able to hide the empty cart after reload, but not without reload.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Just write the script line in below file.

You will find below code lines in file around 470 line number.

$("#header .cart_block").stop(true, true).slideUp(200);
$('.cart_block_no_products:hidden').slideDown(450);
$('.cart_block dl.products').remove();

Add this line.

$('.shopping_cart').hide();
Edited by sandipchandela (see edit history)
Link to comment
Share on other sites

  • 1 month later...

Hey sandipchandela,

I cannot find 

$("#header .cart_block").stop(true, true).slideUp(200);

$('.cart_block_no_products:hidden').slideDown(450);

$('.cart_block dl.products').remove();

 

anything related to this in blockcart.tpl :/

 

File name- ajax-cart.js located in following folder.

 

Location  -  \prestashop\themes\default-bootstrap\js\modules\blockcart

 

$('.shopping_cart').hide();

Link to comment
Share on other sites

  • 4 months later...

Hi everybody,

 

adding the line (470)... $('.shopping_cart').hide(); ...do the job (file :  \prestashop\themes\default-bootstrap\js\modules\blockcart)

 

But i don't want the cart be displayed when first loading the home page ... the cart is empty but displayed !

What can i do to fix this = not display the cart whenever it's empty... that's mean also when first time loading the home page?

Thanks.

Cheers

Link to comment
Share on other sites

Hi,

 

There is a much much more simple way to do this

 

in blockcart.tpl above <div class="shopping_cart"> put {if $cart_qties >= 1} and then close it off with {/if} at about line 200 after the closing div

 

That way it won't be loaded till the cart is equal to or greater than 1 item. The pop up confirmation will still load as this is outside the {if $cart_qties >= 1}...{/if}

 

Regards

 

Clint

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

Hi,

Thank you Clint... i tried it.. seems to work.. but one drawback : when you put your first product in the cart you need to refresh/reload the page (or change page) in order to see the cart with your product.... I need the cart to be viewed/displayed once the cart is not empty.

 

Thanks for your help.

cheers

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...