Blog

Development of a Joomla and Phoca Cart Shop System Plugin to show Rich Snippet Data on each Product View pages

I needed to develop this Plugin to render the Product Rich Snippets (items) for the Phoca Cart Component in JSON format.
How it works is pretty simple:

  1. Plugin have to works on item view only;
  2. get the ID of the displayed product;
  3. obtain the Product data from Database according to the Product ID;
  4. obtain the Review and Rating data from Database according to the Product ID;
  5. obtain the name of the Manufacturers from Database according to their ID;
  6. some Handlers for Stock and Conditions;
  7. render everything before closing the TAG Head;

What we need to render is this (with some test values):

<!-- START Item Rich Snippet - ver. 1.0.6 -->
<script type="application/ld+json">
{
	"@context": "https://schema.org/",
	"@type": "Product",
		"name": "Item name",
		"image": ["https://www.website.it/images/phocacartproducts/test/prod-demo.jpg"],
		"description": "Neque eros, molestie et diam vulputate, pellentesque congue risus. Nam imperdiet tristiq...",
		"sku": "0012456789",
		"gtin13":"8004567891946",
		"review": {
		"@type": "Review",
		"reviewRating": {
			"@type": "Rating",
			"ratingValue": "2"
			},
		"author" : {
			"@type": "Person",
			"name": "Donec malesuada"
			},
		"reviewBody": "Duis neque eros, molestie et diam vulputate, pellentesque congue risus. Nam imperdiet tristi..."
		},
      "aggregateRating": {
	  	"@type": "AggregateRating",
		"ratingValue": "2",
		"bestRating": "5",
		"ratingCount": "6"
      },
	"brand": {
		"@type": "Thing",
		"name": "The company"
		},
	"offers": {
		"@type": "Offer",
		"priceCurrency": "EUR",
		"price": "109.0000",
		"priceValidUntil": "2021-12-07",
		"itemCondition": "New",
		"availability": "https://schema.org/InStock",
		"URL": "https://www.website.it/shop/category/6-item",
		"seller": {
			"@type": "Organization",
			"name": "The company"
		}
	}
}
</script>
<!-- END Item Rich Snippet - ver. 1.0.6 -->

From version 1.0.6 with AggregateRating and Reviews if you have these featured enabled on your website.

You can download the Plugin here (tested on: Phoca Cart 3.5.4 and Joomla 3.9.23 with PHP 7.3)

Thanks, Fabrizio.

 
 
 
  • |
  • |
  • Modified: 18 / 12 / 2020