Re: Getting the mini-cart to follow you down the page.
Glad you think so. I made this a module that you could enable/disable in the admin. I still may decide to package this module for sale later, but I will post the code for now.
First you need to run this sql code:
delete from xcart_modules where module_name = 'Floating_Cart';
delete from xcart_config where category = 'Floating_Cart';
insert into xcart_modules (module_name,module_descr,active) values ('Floating_Cart','Float the mini-cart down the page when scrolled.','Y');
replace into xcart_languages (code,name,value,topic) values ('en','module_name_Floating_Cart','Floating Cart','Modules');
replace into xcart_languages (code,name,value,topic) values ('en','module_descr_Floating_Cart','This module allows the right bar to follow users down the page.','Modules');
Then make a folder /**YOUR_SKIN_FOLDER**/modules/Floating_Cart
Upload the following code to a new file named jquery.floating_cart.js that you create in the new folder:
var scrollTimer = -1;
function bodyScroll() {
if (scrollTimer != -1)
clearTimeout(scrollTimer);
scrollTimer = window.setTimeout("scrollFinished()", 500);
}
function scrollFinished() {
var currentPos = $(window).scrollTop() + 10;
if (currentPos>200){
var nowTop = (currentPos-120) + "px";
} else {
var nowTop = 0 + "px";
}
$("#right-bar").animate(
{ top: nowTop }, {
duration: 500,
easing: 'swing'
});
return false;
}
window.onscroll = bodyScroll;
Then to hook it all up, in /**YOUR_SKIN_FOLDER**/customer/service_js.tpl add to the bottom:
{if $active_modules.Floating_Cart ne ''}
{load_defer file="modules/Floating_Cart/jquery.floating_cart.js" type="js"}
{/if}
Please don't try this on your live store, it is untested by my standards. Please do feel free to use this mod, after you have tested it in your dev environment.
If you do use it, please let me know by posting here. If you can provide a link to your store so others can see it in action, that would be great as well. If you have problems following these instructions, feel free to ask questions. I will attempt to answer any issues, but can't guarantee support.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey
XcartGuru
X-cart Tutorials | X-cart 5 Tutorials
Check out the responsive template for X-cart.
|