Add Pinterest Button to WP eCommerce Product Pages

Pinterest has been a great source of traffic for a number of our projects. We were looking for a simple way to let our visitors Pin our sites products using WP eCommerce and found no simple solutions.

Although WP eCommerce has Pinterest functionality built in under their the marketing tab’s “share button” we found it glitchy and overcomplicated.

To add Pinterest to your WordPress eCommerce site simply add the following code to the wpsc-single_product.php file in your themes directory.

<?php $stripdescript = wpsc_the_product_description();
$stripeddescript = strip_tags($stripdescript);?>
 
<a target="_blank" href="http://pinterest.com/pin/create/button/?url=<?php echo wpsc_the_product_permalink(); ?>&media=<?php echo wpsc_the_product_image(); ?>&description=<?php echo $stripeddescript; ?>" class="pin-it-button" count-layout="none"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>

Then add the following to your header.php file.

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

This code could be improved or even made into a stand alone plugin. Let us know if you have a way to improve it!

This entry was posted in Code. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *