Categories: Magento

How To Add Facebook Share and Twitter Tweet Button in Magento.?

Magento add Social Media Button : Adding a ‘Facebook Share button‘ and a ‘Twitter Tweet button’ to your Magento pages and products is simple but you have to use the precise code to get the specific result. These button allow the user to share this information on major social media sites with facebook share and Twitter tweet. You might find these button on product pages of E-Commerce websites.


  • 1. You can use this code for sharing/tweeting specific CMS pages or product detail pages in Magento
  • 2. This code should go inside the /app/design/frontend/default/yourtheme/template/catalog/product/view.phtml
  • 3. You can put this in various locations, but I recommend sharing it directly after the product description on my product detail page
//Add following Snipped anywhere in the Site for Facebook and Twitter Button in Magento

<div>
<?php if ($this->canEmailToFriend()): ?>
<div><a href=”<?php echo $this->helper(‘catalog/product’)->getEmailToFriendUrl($_product) ?>”><?php echo $this->__(‘Email to a Friend’) ?></a></div>
<?php endif; ?>
<div><a href=”http://twitter.com/share” data-count=”none” data-via=”PUT YOUR TWITTER NAME HERE”>Tweet</a></div>
<div><script src=”http://platform.twitter.com/widgets.js” type=”text/javascript” ></script><div id=”fb-root”></div><script src=”http://connect.facebook.net/en_US/all.js#appId=233211453363057&amp;xfbml=1″></script><fb:like href=”” send=”true” layout=”button_count” width=”250″ show_faces=”false” font=””></fb:like></div>
<br style=”clear:both;” />
</div>

//

Be sure to change PUT YOUR TWITTER NAME HERE to the actual Twitter username for your Tweet button is affiliated with. This will automatically add the #TwitterID tag to the end of the shared tweet respectively.

Magento CSS fix for Facebook Share and Twitter Tweet Button

Now for the CSS styling part. Add the following code at the end of your theme’s CSS file which is most likely located in /skin/frontend/default/yourtheme/css/styles.css

.share { background: #F8F8F8; border:1px solid #CCC; padding: 8px; margin:0 0 5px 0;}
.email-friend a {display:block; margin:0 10px 0 0; float:left;clear:both;width:55px;height:20px;background:url(../images/email.png) no-repeat; font-size:0;text-decoration:none; text-indent:-9999px; }
.tweet { float: left; width: 55px; height:20px; margin-right: 10px;}
.fbShare { float: left; width: 175px; height: 20px;}

You can use this code anywhere in the site for putting sharing button in the front end

Rohan pathak

Recent Posts

Modern Toys, Magical Moments: Why the Best Toy Shop in Noida Is More Than Just a Store

When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…

6 months ago

Rediscovering Joy: A New Era of Creativity & Comfort in Toy Stores

In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…

7 months ago

Unboxing Imagination: Discovering the Joy of Play at a Toy Store in Noida

In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…

7 months ago

Imagination Unboxed: Discover Joy at the Toy Shop in Delhi

In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…

7 months ago

Play with Purpose: Discovering the Ultimate Toy Store in Noida

When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…

7 months ago

From Tears to Toys: Exploring Modern Childhood through Delhi’s Favorite Toy Shop

In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…

7 months ago