Hello Friends,
This article is use to share your product in facebook and twitter. Here is the simple code to add into app/design/frontend/<theme>/<theme>/template/catalog/product/view.phtml
Please check first your theme path and also detail page file. here is the default path
app/design/frontend/base/default/template/catalog/product/view.phtml
You can find file path to enable path hint from back-end.
Add below code and save the file
<?php $_productName = urlencode(trim($_helper->productAttribute($_product, $_product->getName(), 'name')))?>
<?php $_productImageUrl = urlencode(trim($this->helper('catalog/image')->init($_product, 'image')))?>
<?php $_productUrl = urlencode(trim($_product->getProductUrl()))?>
<?php $_u = 'p[url]=' . $_productUrl . '&p[images][0]=' . $_productImageUrl . '&p[title]=' . $_productName . '&p[summary]=' . urlencode(trim($_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description'))); ?>
<div class="social-links" style="float: right;">
<a href="javascript:void(0);" title="<?php echo $this->__('Share on Facebook') ?>" class="link-facebook svg-replace" onclick="window.open( '<?php echo 'http://www.facebook.com/sharer.php?s=100&' . $_u; ?>' , '_blank' ,'height=500,width=500'); return false">
<img class="fb-icon" style="" src="<?php echo $this->getSkinUrl(); ?>images/social-fb-icon.png" alt="Share Facebook" />
</a>
<a href="javascript:void(0);" target="_blank" title="<?php echo $this->__('Share on Twitter') ?>" class="link-twitter svg-replace" onclick="window.open( '<?php echo 'http://twitter.com/home?status=' . $_productName . '+' . $_productUrl; ?>' , '_blank' ,'height=500,width=500'); return false">
<img class="twitter-icon" style="" src="<?php echo $this->getSkinUrl(); ?>images/social-twitter-icon.png" />
</a>
</div>
Notes: This code will help you in core php, WordPress, Drupal, Joomla and other framework also you just need to setup parameter and it will work.
Thank you,
Enjoy Your Self,