Facebook ‘Like’ button for PrestaShop product pages
May 3, 2010 PrestaShop Customization, PrestaShop Tips
Is this useful? Like it.
Facebook ‘Like’ button/widget is one of the plugins available from the new Facebook Social Plugins.
To add the Facebook ‘Like’ button on every product page, you just need to add one line of code to one file.

STEP 1
Open this file with any text editor:
\themes\THEME_NAME\product.tpl
Where THEME_NAME is the folder name of the theme you are using.
STEP 2
Copy this code:
<iframe src="http://www.facebook.com/plugins/like.php?href={php} echo 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; {/php}&layout=standard&show_faces=false&width=450&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:35px; margin-top:10px; margin-bottom: 0px"></iframe>Paste the code to around line 87 — or right after this line:Â {include file=$tpl_dir./breadcrumb.tpl}

OPTIONAL: CUSTOMIZATION
The Facebook plug-in code added to the PrestaShop file was obtained from Facebook (have a look, but you do not need to get the code from there).
There are a few parameters that you may want to change to the code that you copied from STEP 2 above:
- show_faces=false — Change to true if you want the widget to display the thumbnail photos of those who have ‘liked’ your product.
- colorscheme=light – Change to dark if your page is dark in color.
- height:35px — This was arbitrarily choosen. If you choose to display ‘faces’, then you should increase the height of the widget (80px or more).
Compatibility: PrestaShop all versions
Note: Example is provided as is. Not guaranteed to work across all hosting platforms (especially Windows server). Try it out before leaving it live on your site.













May 25th, 2010 at 7:29 pm
It works just perfect! Thank you very much
May 28th, 2010 at 7:54 pm
Great plugin.
June 1st, 2010 at 10:18 pm
After read the instructions 5 times I think I knw whats missing? Where do you add the name or ID to the page you want people to like?????? Please help with this Thanks!
June 1st, 2010 at 10:32 pm
I found out that you can use the internal Global variables that are used by the smarty template system from prestashop. So you dont have to resort to hard php code, and it might even work on windows machines…..
id}-{$product->link_rewrite}.html&layout=standard&show_faces=false&width=450&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:35px; margin-top:10px; margin-bottom: 0px">
June 1st, 2010 at 10:38 pm
Somehow or other my post did not work with the included iframe variable.
Basically the only thing i changed is this line :
src="http://www.facebook.com/plugins/like.php?href={$base_dir}{$product->id}-{$product->link_rewrite}.html
I have added the following smarty vars :
{$base_dir} : your website url
(use $base_dir_ssl if you are running on https)
{$product->id} : ID number of the product
{$product->link_rewrite} : link name of the product
June 4th, 2010 at 10:04 am
No longer works, there Another Way? =(
June 4th, 2010 at 1:14 pm
Tommy,
Just copy the line of code provided, no need to change anything. It’s just one line of HTML code.. which you can just remove anytime.
Uddhava,
Thanks. My example code was chosen because it’s the simplest way and works whether Friendly URL is enabled or disabled. (yes, may not work with Windows server… but most stores are on Linux or unix based servers anyway)
June 4th, 2010 at 1:14 pm
Will,
The Like button seems to be randomly generating error lately. And it seems that it’s happening all over the web. Not sure whether Facebook.com has changed something. Read the report at http://mashable.com/2010/06/01/facebook-like-button-broken/
June 5th, 2010 at 1:06 am
Finally got it to work !! I didn’t do any thing different but tried again and it worked! The thing is I went to look for it on facebook and there was nothing??? WTH!
June 5th, 2010 at 10:42 am
Yes, Facebook seems to have problems with the Like button lately. They are working to fix it:
http://mashable.com/2010/06/01/facebook-like-button-broken/
If you can’t see anything in your Facebook account after you Liked a product, then you may have to wait for Facebook to fix/change/improve it, as it can’t be controlled by any code on our side.
For those who can’t get it to work, maybe try again later.
June 21st, 2010 at 12:54 am
Thanks a lot! it works fine!!!
June 23rd, 2010 at 12:01 pm
It worked fine on my site (driven on Linux) it is the greatest add-on i found, thank you very much for this usefull customization
July 6th, 2010 at 10:47 pm
Worked a treat and perfect
July 14th, 2010 at 8:53 pm
Well, it`s perfect! Thanks a lot!
July 28th, 2010 at 5:22 am
This was fast and easy. Thank you for your information!!!
August 19th, 2010 at 8:41 pm
Thanks a Lot! Works like a charm
you have saved me a day!
August 22nd, 2010 at 8:49 pm
it work perfect !!!!
what a great job !!!