Facebook "LIKE" on your osCommerce shop

Jan asks;
possible to put the new like button on osc
Yep, and it's super simple, using this quick and dirty code.
Step 1: Add this code to your header, footer, or wherever you want the like button to show;
-
<fb:like
-
href="<?php echo HTTP_SERVER . $_SERVER['REQUEST_URI']; ?>"
-
layout="standard"
-
show_faces="true"
-
width="<?php echo BOX_WIDTH-30; ?>"
-
action="like"
-
font="trebuchet ms"
-
colorscheme="light"></fb:like>
Step 2: Get yourself an Application ID from here.
Step 3: Add this code to the bottom of either /includes/footer.php (pre rc3) or includes/template_bottom.php (rc3), making sure to substitute "your app id" with your actual app id;
-
<div id="fb-root"></div>
-
<script src="http://connect.facebook.net/en_US/all.js"></script>
-
<script>
-
FB.init({appId: 'your app id', status: true, cookie: true, xfbml: true});
-
FB.Event.subscribe('auth.sessionChange', function(response) {
-
if (response.session) {
-
// A user has logged in, and a new cookie has been saved
-
} else {
-
// The user has logged out, and the cookie has been cleared
-
}
-
});
-
</script>
Done.
Code needs to be cleaned up for real use, but this should give you enough of an idea to be able to do what you need to do.





This code works great other than one thing. It doesn't show up when used in IE. Works fine in Chrome though. Any thoughts?
Comment by Jason — April 29, 2010 @ 11:14 pm
Please make sure to attribute my posts with a working URL. Thanks
IE requires the js code to be placed the opposite way around. IE, instead of in the footer, hav e it in the header.
Comment by Gary — May 4, 2010 @ 2:18 pm
Strange…I tried that already and still for some reason it doesnt show up but I did notice that it causes IE to give an error regarding a runtime error when that code is placed in the header.
Comment by Jason — May 4, 2010 @ 2:32 pm
Danke – funktioniert wunderbar
Comment by mKd — April 7, 2011 @ 8:56 am
so very confused just got my OsC site in August I just don't know WHERE the facebook code goes how do I get to the header is it in the index.php? Do I have to have a special program to open this? I am really a newbie would appreciate any guidance I have been searching in the forums and online and I am just as confused as ever.
Comment by Diana — November 5, 2011 @ 3:50 am
1 page in oscommerce can be made of many files. Take the example of "product_info.php";
includes/template_top.php
includes/header.php
product_info.php
includes/footer.php
includes/template_bottom.php
a language file
any other files that these call
images
javascript files
and more
Suggest that you need to get straight in your mind how oscommerce hangs together. In general, header edits are done in template_top or header.php
Any type of text editor will do, eg notepad, ultra-edit. Do NOT use any type os wysiwyg editor such as dreamweaver or frontpage.
Comment by Gary — November 7, 2011 @ 11:11 pm