Facebook ‘Like’ button for PrestaShop product pages

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.

facebook_like

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}&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;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}

facebook_like_code

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:

  1. show_faces=false — Change to true if you want the widget to display the thumbnail photos of those who have ‘liked’ your product.
  2. colorscheme=light – Change to dark if your page is dark in color.
  3. 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.

Premium PrestaShop themes from $22 only. Guaranteed unbeatable best value! Give your business an advantage over others! Click to view now!

17 Responses to “Facebook ‘Like’ button for PrestaShop product pages”

  1. possek Says:

    It works just perfect! Thank you very much :)


  2. Leon Says:

    Great plugin.


  3. Tommy Says:

    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!


  4. Uddhava Says:

    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">


  5. Uddhava Says:

    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


  6. Will Says:

    No longer works, there Another Way? =(


  7. admin Says:

    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)


  8. admin Says:

    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/


  9. TommyBoy Says:

    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!


  10. admin Says:

    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.


  11. smoke Says:

    Thanks a lot! it works fine!!!


  12. djtrale Says:

    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 :)


  13. OBS-PCS Says:

    Worked a treat and perfect


  14. Artem Says:

    Well, it`s perfect! Thanks a lot!


  15. Angela Says:

    This was fast and easy. Thank you for your information!!!


  16. Rimantas Says:

    Thanks a Lot! Works like a charm ;) you have saved me a day!


  17. chyu Says:

    it work perfect !!!!
    what a great job !!!


Leave a response.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">