+sub product_to_schemaorg {
+ my ($include_url, %data) = @_;
+ my $stock = $data{stock} > 0 ? 'InStock' : 'OutOfStock';
+ +{
+ '@context' => 'http://schema.org/',
+ '@type' => 'Product',
+ name => $data{title},
+ image => "/static/fullpics/$data{product}-1.jpg",
+ description => $data{summary},
+ offers => {
+ '@type' => 'Offer',
+ price => ($data{price} =~ s/(..)$/\.$1/r),
+ priceCurrency => 'GBP',
+ availability => "http://schema.org/$stock",
+ ($include_url ? (url => "/details/$data{product}/" . make_slug $data{title}) : ())
+ }
+ }
+}
+