When users post a link to your products on Facebook, its nice for the automatic link to show a picture of an actual product.
Unfortunately Zen Cart doesn’t have this facility out of the box, but its not too tricky to add it yourself.
In your template’s html_header.php add the following lines for all the Facebook Open Graph tags:
echo $_SERVER['REQUEST_URI'];?>" />
if(META_TAG_PRODUCT_IMAGE=="META_TAG_PRODUCT_IMAGE"){?>
/includes/templates/YOU_TEMPLATE/images/logo.png" />
}else{?>
/images/ echo META_TAG_PRODUCT_IMAGE;?>" />
} ?>
Note: this is using a new DEFINE variable called META_TAG_PRODUCT_IMAGE.
This needs to be defined in your modules/meta_tags.php file.
(use an override for your template obviously by copying the existing one into a folder called YOUR_TEMPLATE. Also check what the default directory for your product images is – this code is assuming they are directly beneath the images folder. You’ll need to do extra work to figure ou if they are in more complex subdirectories)
In the line around 194 that is building the SQL to pull data from the products table add the following field to the list:
p.products_image
Then around line 208 below where it says // custom meta tags per product add the following line:
$meta_products_image = $product_info_metatags->fields['products_image'] ;
define('META_TAG_PRODUCT_IMAGE', $meta_products_image);
(Note: I have moved both lines together as it seemed to make it work on ZenCart 1.5. It looks like there were more if statements added in this version!)
Thats it. You can see it in work here http://www.thepartypirate.com and in version 1.5 http://www.framecraftonline.com