Tuesday, October 12

How to add Facebook Like button to your product page

1. Open view.phtml in app/design/frontend/default/[yourtheme]/template/catalog/product

2. Find in that file this line

($_product->getName()), 'name')

3. You will see the code above is inside the header HTML mark up. Under the header (this is the location that I want to set up. However, you are welcome to put the Like button anywhere in the page that you want), put this line of code

<?php
          $url = $_product->getProductUrl()
?>

4. Then, put this Facebook Like code under it

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo $url; ?>&amp;layout=button_count&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>

1 comment:

  1. Thank you! This was incredibly helpful. I now have a facebook "like" button on every individual product page of my site. Thanks again!!

    ReplyDelete