How to put google rich-snippets in your Opencart template

As you know , Google encourages web shopping cards to embed rich-snippets to their product pages.
I am going to show how we can add markups to our product in Opencart, so that google can provide detail information in search results. This can help to attract more users to your shopping cart and help them to find their desire product easier.

So lets assume you have a Opencart template called mytemplate.

Then you should modify the following file:
/catalog/view/theme/mytemplate/template/product

Then you put following java script code in your php file:

 

     
<script type="application/ld+json">
{
   "@context": "http://schema.org/",
        "@type": "Product",
        "name": "<?php echo $heading_title; ?>",
        "image": "<?php echo $thumb; ?>",
        "description": "<?php echo $heading_title; ?>",
        "brand": {
            "@type": "Product",
            "name": "Your Organisation Name"
        },
        "offers": {
            "@type": "Offer",
            "priceCurrency": "AUD",
            "price": "<?php echo str_replace('$','',str_replace(' AUD','',$price)); ?>",
            "priceValidUntil": "2020-11-05",
            "itemCondition": "http://schema.org/NewCondition",
            "availability": "http://schema.org/InStock",
            "seller": {
                "@type": "Organization",
                "name": "Your Organisation Name"
            }
        }
}
</script>

One thought on “How to put google rich-snippets in your Opencart template

Leave a Reply

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