Google+

Pages

Wednesday, July 11, 2012

Magento: How to add Pin it button on product pages

Hi all,

To add Pin it button on product pages, just use the following process:

Add the following code, right where you want to show the pin it button:

<a href="http://pinterest.com/pin/create/button/?url=<?php echo $this->helper('core/url')->getCurrentUrl(); ?>&media=<?php echo $productImage; ?>" class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>

Note: Where $productImage is the url of product image.

Add the following code to add pinit.js once just above after the above code:

<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>

Note: Remember that you have to include this line only once on whole page.

Note: horizontal can be replaced by vertical or none


That's it.. Enjoy :)

No comments: