Use Product Name as Open Graph Description in ISC

This mod is not needed when Use Product Name as Meta Description in ISC is deployed since Open Graph description will be copied from Meta Description automatically for all products.

Problem

By default, the Open Graph description tag in Product page is always empty unless you define the meta description manually for each product.

<meta property="og:description" content="" />

Solution

Use product name to construct Open Graph description tag automatically if the meta description is empty.

In /public_html/includes/classes/class.product.php

Find (around line 254)

$this->_opengraph_description = $row['prodmetadesc'];

Replace

//===========================
// MOD START
// Use product description as Open Graph deescription if product meta description is empty
//===========================
// $this->_opengraph_description = $row['prodmetadesc'];
if($row['prodmetadesc'] == ''){
	$this->_opengraph_description = 'Buy '.$row['prodname'].' for '.CurrencyConvertFormatPrice($row['prodprice']).' with Free Shipping Worldwide (In Stock)';
}else{
	$this->_opengraph_description = $row['prodmetadesc'];
}
// MOD END
//===========================

Finally, go to an Open Graph checker to confirm your tags:

Result

<meta property="og:type" content="product" />
<meta property="og:title" content="IBM Lenovo Motherboard 11 Pin to Standard 9 Pin USB Adapter Cable" />
<meta property="og:description" content="Buy IBM Lenovo Motherboard 11 Pin to Standard 9 Pin USB Adapter Cable for $9.99 with Free Shipping (In Stock)" />
<meta property="og:image" content="https://www.moddiy.com/product_images/o/320/IBM_Lenovo_Motherboard_11_Pin_to_Standard_9_Pin_USB_Adapter_Cable_%281%29__17946_zoom.jpg" />
<meta property="og:image:width" content="800" />
<meta property="og:image:height" content="800" />
<meta property="og:image:alt" content="IBM Lenovo Motherboard 11 Pin to Standard 9 Pin USB Adapter Cable" />
<meta property="og:url" content="https://www.moddiy.com/products/IBM-Lenovo-Motherboard-11-Pin-to-Standard-9-Pin-USB-Adapter-Cable.html" />
<meta property="og:site_name" content="modDIY.com" />

1 Reply to “Use Product Name as Open Graph Description in ISC”

Leave a Reply

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