Scrolling Cart Script for a particular catalog item

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2016 11:57 AM
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
Thank you,
Karen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2016 08:26 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2016 10:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2016 08:50 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2016 04:30 AM