Forum
Social cards for product sharing
What is the best method to pass product information into the OG cards for facebook and twitter etc? I've started out trying the method in the docs for perch content but not sure if it works the same for the shop:
# get the post
$post = perch_shop_product(array(
'template' => 'products/product_item.html',
'filter' => 'slug',
'match' => 'eq',
'value' => perch_get('slug'),
'skip-template' => 'true',
'return-html' => 'true',
));
# set up the variables
$title = $post['title'];
$description = $post['0']['description'];
$fbimage = $post['0']['imageCarousel'];
$domain = 'https://'.$_SERVER["HTTP_HOST"];
$url = $domain.$_SERVER["REQUEST_URI"];
perch_layout('global.head', array (
'description' => $description,
'og_title' => $title,
'og_type' => 'article',
'sharing_image' => $domain . $fbimage,
'url' => $url
));
perch_layout('shop.header', array(
'shop' => true //Page indicator for nav
));
?>
Currently just getting the following warning: Warning: PDO::quote() expects parameter 1 to be string, array given in
I think you want something more akin to:
Perfect thanks!