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
Views: 1,573
New Zenner
Has anyone managed to get Pinterest's Rich Pin functionality working on Zen Cart and is willing to share the code?
Thanks
Lee
New Zenner
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/
Totally Zenned
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
New Zenner
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 :)
Totally Zenned
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
Totally Zenned
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
New Zenner
<?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 ?> ```jeking:
Third times a charm, right? This code works for both regular and specials and passes the Rich Pin validation.
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..
New Zenner
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!
New Zenner
Yes, thanks for catching my oversight on special vs base pricing, and for continuing to provide updates.
Tell staff why this post should be reviewed.