Jump to content

How can I hide my cart when there is no article in the basket


Recommended Posts

Dear All,

 

I am trying hard to find a solution to hide my cart (block_cart.tpl) when there is not article.

 

I create a simple module (to avoid modifying the block_cart module).

 

When there is a article in the basket, my block_cart.tpl is moving with the window scrool. It works fine, but I would like to additonaly hide the block_cart.tpl, when the basket is empty as well

 

And then I would like to add some javacsript/jquery code to do this.

$(document).ready(function(){
//	    ajaxPanier.refresh();

var name = "#cart_block"; 
var menuYloc = null;

menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px"))) 
//$(name).css('display','none');

$(window).scroll(function () { 
    var offset = menuYloc+$(document).scrollTop(); 


 if(offset > 200){
  $(name).animate({top:offset+"px"},{duration:500,queue:false});
 }else{
  $(name).animate({top:menuYloc+"px"},{duration:500,queue:false});
 }

   });
});

to obtain my goal,

 

Some has a solution for me?

 

This will help a lot ans thank in adance

Link to comment
Share on other sites

  • 4 weeks later...

Hi,pierrot10. You can combine javascript and smarty.

 

In smarty add a condition to hide the cart if there are not products by applying css style

display:none

, and in javascript add the function to display cart when a product is added.

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...