Web Analytics

Fill the form & Get Installation Support

How To Add Facebook Like Button On Your Magento Store?

Today many sites you visit have a link to like & share their article, page or product with your Facebook friends. Facebook sharing is increasing day by day to reach the maximum number of people hence this article will it little easier for your customer to share your products with their Facebook friends.

To explain you in a better way we have used the Magento default theme as a reference. You can adjust your code slightly if you are using a custom theme.

Get Facebook Like Button code

Here, we are adding Facebook like button to your product view.

With your favourite text editor, I like Notepad++ ,
open
/app/design/frontend/base/default/template/catalog/product/view.phtml and around line 57 find the following code:

<br/>

<span class=”h1″><?php echo $_helper->productAttribute($_product, $_product->getName(), ‘name’) ?></span>

Place the following code on a new line below:

<br />

<div id=”fb-root”></div><br />

<script>(function(d, s, id) {

var js, fjs = d.getElementsByTagName(s)[0];

if (d.getElementById(id)) return;

js = d.createElement(s); js.id = id;

js.src = ‘https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.12’;

fjs.parentNode.insertBefore(js, fjs);

}(document, ‘script’, ‘facebook-jssdk’));</script><br />

<fb:like href=”<?php echo $_product->getProductUrl() ?>” send=”false” show_faces=”false”></fb:like><br />

 

That block of code should look something like this :

<br />

<div class=”product-name”><br />

<span class=”h1″><?php echo $_helper->productAttribute($_product, $_product->getName(), ‘name’) ?></span>

<div id=”fb-root”></div><br />

<script>(function(d, s, id) {

var js, fjs = d.getElementsByTagName(s)[0];

if (d.getElementById(id)) return;

js = d.createElement(s); js.id = id;

js.src = ‘https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.12’;

fjs.parentNode.insertBefore(js, fjs);

}(document, ‘script’, ‘facebook-jssdk’));</script><br />

<fb:like href=”<?php echo $_product->getProductUrl() ?>” send=”false” show_faces=”false”></fb:like><br />

</div><br />

 

Refresh your product view page and see the like button. If you don’t see any change then you may need to refresh the Blocks HTML output cache in System > Cache Management.

To Conclude

Social media has become an inseparable organ of the businesses today. You can use social media for social advertisement, social login plugins or social sharing. It is helping businesses in countless ways. Which kind of social media option do you use in your business? Do let us know in the comment section below.





    Recent Articles

    Author Info

    Author Image

    Eshika Is a bibliophile and conversationalist. Her life revolves around writing , photography, presentation and repeat. "go with the Flow" is her approach in life.

    Get a Free Quote





      /* second popup */

      CONTACT US (FREE 25 HOURS DEVELOPMENT)

      (We Operate Globally)