Forums / All Other Contributions/Addons / Pinterest Rich Pins

Pinterest Rich Pins

Views: 1,573

Results 1 to 9 of 9
25 Aug 2014, 4:53 PM
#1
olcs avatar

olcs

New Zenner

Join Date:
Dec 2011
Posts:
92
Plugin Contributions:
0

Pinterest Rich Pins

Has anyone managed to get Pinterest's Rich Pin functionality working on Zen Cart and is willing to share the code?

Thanks

Lee

26 May 2015, 4:01 AM
#2
andy_m avatar

andy_m

New Zenner

Join Date:
Apr 2015
Location:
United States
Posts:
15
Plugin Contributions:
0

Re: Pinterest Rich Pins

I have..

My approach was pretty simple..

In the file \includes\templates\My_Template\templates\tpl_product_info_display.php

At the very end between

<!--bof Form close-->

and

</div>

I entered..

<?php
//Schema.org tags
?>
  <meta property="og:site_name" content="My Website Title Here" />
    <div itemscope itemtype="http://schema.org/Product">
    <meta itemprop="name" content="<?php echo $products_name; ?>" />
    <meta itemprop="image" content="<?php echo HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $products_image; ?>" />
    <meta itemprop="url" content="<?php echo $canonicalLink; ?>" />
  
  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <meta itemprop="price" content="<?php echo zen_get_products_special_price($_GET['products_id'], false) ; ?>" />
    <meta itemprop="priceCurrency" content="USD" />
  </div>
  </div>
<?php
//Schema.org tags
?>

I then validated my product pages at..
https://developers.pinterest.com/rich_pins/validator/

28 May 2015, 8:38 PM
#3
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: Pinterest Rich Pins

That code works great when the product is on special. This will work for special and regular priced items.

<?php
//Schema.org tags
?>
<meta property="og:site_name" content="The Untreed Reads Store" />
<div itemscope itemtype="http://schema.org/Product">
  <meta itemprop="name" content="<?php echo $products_name; ?>" />
  <meta itemprop="image" content="<?php echo HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $products_image; ?>" />
  <meta itemprop="url" content="<?php echo $canonicalLink; ?>" />
  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <?php if (zen_get_products_special_price($_GET['products_id'] == null )) {?>
    <meta itemprop="price" content="<?php echo zen_get_products_base_price($_GET['products_id'], false) ; ?>" />
    <?php
		  }else{
	  ?>
    <meta itemprop="price" content="<?php echo zen_get_products_special_price($_GET['products_id'], false) ; ?>" />
    <?php } ?>
    <meta itemprop="availability" content="in stock" />
    <meta itemprop="priceCurrency" content="USD" />
  </div>
</div>
<?php
//Schema.org tags
?>

Jim
Wheaton Website Services

28 May 2015, 9:23 PM
#4
olcs avatar

olcs

New Zenner

Join Date:
Dec 2011
Posts:
92
Plugin Contributions:
0

Re: Pinterest Rich Pins

Hi both,

Thank you so much for your posts, they have been really helpful.

I have used your example Jeking however I am having some problems..

I have used your code exactly as is except for changing the site name and swapping from USD to GBP

Firstly, it does not show the price details at all for my products if the product is not on special.

Secondly, I have pinned an item that is not in stock however on Pinterest it is still showing as in stock. Is there a way to add the code so that it checks the availability as I think in stock is just hard coded in the example you gave..

Thanks in advance for any additional help you may be able to give, I really appreciate it :)

29 May 2015, 1:04 PM
#5
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: Pinterest Rich Pins

Correction to the code in post #3. Use this instead:

<?php
//Schema.org tags
?>
<meta property="og:site_name" content="The Untreed Reads Store" />
<div itemscope itemtype="http://schema.org/Product">
  <meta itemprop="name" content="<?php echo $products_name; ?>" />
  <meta itemprop="image" content="<?php echo HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $products_image; ?>" />
  <meta itemprop="url" content="<?php echo $canonicalLink; ?>" />
  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <?php if (zen_get_products_special_price($_GET['products_id'] === null )) {?>
    <meta itemprop="price" content="<?php echo zen_get_products_base_price($_GET['products_id']) ; ?>" />
    <?php
	}else{
     ?>
    <meta itemprop="price" content="<?php echo zen_get_products_special_price($_GET['products_id']) ; ?>" />
    <?php } ?>
    <meta itemprop="availability" content="in stock" />
    <meta itemprop="priceCurrency" content="USD" />
  </div>
</div>
<?php
//Schema.org tags
?>

Availability is optional. If your items are not all 'in stock', simply remove that line from the code above.

Jim
Wheaton Website Services

29 May 2015, 2:20 PM
#6
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: Pinterest Rich Pins

Third times a charm, right? This code works for both regular and specials and passes the Rich Pin validation.

<?php
//Schema.org tags
?>
<meta property="og:site_name" content="Your Store Name" />
<div itemscope itemtype="http://schema.org/Product">
  <meta itemprop="name" content="<?php echo $products_name; ?>" />
  <meta itemprop="image" content="<?php echo HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $products_image; ?>" />
  <meta itemprop="url" content="<?php echo $canonicalLink; ?>" />
  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <?php 
		$special_price = $db->Execute("SELECT * from " . TABLE_SPECIALS . " WHERE products_id = '" . (int)$_GET['products_id'] . "' AND status='1'");
		if ($special_price->RecordCount() > 0) { ?>
    <meta itemprop="price" content="<?php echo zen_get_products_special_price($_GET['products_id']) ; ?>" />
    <?php
		}else{
	 ?>
    <meta itemprop="price" content="<?php echo zen_get_products_base_price($_GET['products_id']) ; ?>" />
    <?php } ?>
    <meta itemprop="availability" content="in stock" />
    <meta itemprop="priceCurrency" content="USD" />
  </div>
</div>
<?php
//Schema.org tags
?>

Jim
Wheaton Website Services

29 May 2015, 7:06 PM
#7
olcs avatar

olcs

New Zenner

Join Date:
Dec 2011
Posts:
92
Plugin Contributions:
0

Re: Pinterest Rich Pins

jeking:

Third times a charm, right? This code works for both regular and specials and passes the Rich Pin validation.

<?php //Schema.org tags ?> <meta property="og:site_name" content="Your Store Name" /> <div itemscope itemtype="http://schema.org/Product"> <meta itemprop="name" content="<?php echo $products_name; ?>" /> <meta itemprop="image" content="<?php echo HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $products_image; ?>" /> <meta itemprop="url" content="<?php echo $canonicalLink; ?>" /> <div itemprop="offers" itemscope itemtype="http://schema.org/Offer"> <?php $special_price = $db->Execute("SELECT * from " . TABLE_SPECIALS . " WHERE products_id = '" . (int)$_GET['products_id'] . "' AND status='1'"); if ($special_price->RecordCount() > 0) { ?> <meta itemprop="price" content="<?php echo zen_get_products_special_price($_GET['products_id']) ; ?>" /> <?php }else{ ?> <meta itemprop="price" content="<?php echo zen_get_products_base_price($_GET['products_id']) ; ?>" /> <?php } ?> <meta itemprop="availability" content="in stock" /> <meta itemprop="priceCurrency" content="USD" /> </div> </div> <?php //Schema.org tags ?> ```

Hi Jeking,

Thanks so much for your time spent on this, it's really appreciated. I almost hate to tell you this, but for some reason this code still doesn't seem to work correctly for products that are not on special. None of the details come across into Pinterest. If the product is on special it works fine..

29 May 2015, 7:15 PM
#8
olcs avatar

olcs

New Zenner

Join Date:
Dec 2011
Posts:
92
Plugin Contributions:
0

Re: Pinterest Rich Pins

OLCS:

Hi Jeking,

Thanks so much for your time spent on this, it's really appreciated. I almost hate to tell you this, but for some reason this code still doesn't seem to work correctly for products that are not on special. None of the details come across into Pinterest. If the product is on special it works fine..

Ignore my previous post. Its just started working!

Thanks so much for this Jeking! It works like a charm :clap:

Availability is optional. If your items are not all 'in stock', simply remove that line from the code above.

All I was getting at was that it would be great if this could be done by some kind of look up from the database that populated the availability rather than have it hardcoded as obviously this code applies to all products across the site, some that will be in stock and some not. I just wondered whether something could check whether the stock level was less that 0 for example and then adjust the availability tag accordingly. Just a thought. Great job though. Thanks!

1 Jun 2015, 1:02 AM
#9
andy_m avatar

andy_m

New Zenner

Join Date:
Apr 2015
Location:
United States
Posts:
15
Plugin Contributions:
0

Re: Pinterest Rich Pins

Yes, thanks for catching my oversight on special vs base pricing, and for continuing to provide updates.