Scrolling Cart Script for a particular catalog item

Cupcake
Mega Guru

Hi am trying this script for my catalog item that I got from the user community and I keep getting an error. Can someone take a look please?

Here is the link where I got the code from: Scrolling Cart for Service Request - Oslova Networks

find_real_file.png

Thank you,

Karen

18 REPLIES 18

amlanpal
Kilo Sage

Hi Karen,



Try the below code in Catalog client script as onLoad:



var adder;


var cartContent;



function onLoad()


{


      try{


              adder = gel('adder');


              adder.style.position = "relative";


      }


      catch(errr){adder == null}


     


      try{


              cartContent = gel('sc_cart_contents');


              cartContent.style.position = "relative";


      }catch(errr){cartContent = null}


     


      window.onscroll = function(){


              try{


                      var y = 12;


                      if (typeof window.pageYOffset != 'undefined')


                              y = window.pageYOffset;


                      else if(typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0)


                              y = document.documentElement.scrollTop;


                      else if(typeof document.body.scrollTop != 'undefined')


                              y = document.body.scrollTop;


                      if(y > 60){


                             


                              if(adder != null) {adder.style.top = y - 60 + 'px';   //alert('adder: '+ adder.style.top );


                              }


                      if(cartContent != null) {cartContent.style.top = y - 60 + 'px'; //alert('cartcintent: '+ cartContent.style.top )


                      }


      }else{


              if(adder != null) {adder.style.top = 0 + 'px';}


                      if(cartContent != null) {cartContent.style.top = 0 + 'px';}


              }


}catch(err){


     


      if(adder != null) {adder.style.top = 0 ;}


              if(cartContent != null) {cartContent.style.top = 0 ;}


      }


}


}




I hope this helps.Please mark correct/helpful based on impact


Receiving the following error:



find_real_file.png


Hi Karen,



I request you to make comment (like below) the line 27 and save it. And again remove the comment from line 27 and save it. Hope this will run.


//cartContent = gel('sc_cart_contents');




I hope this helps.Please mark correct/helpful based on impact


Good morning Amlan Pal - i did comment out the line 27 which did not resolve the issue.



The error is on line 21


find_real_file.png



Thank you again.


Karen