Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Schema.org micro data updates

* Fix price

* Add InStock, OutOfStock, and PreOrder item availability

* Fix manufacturer
  • Loading branch information...
commit f67201f33e07a1fb14020fee9e1c0981977f8dc3 1 parent 2282b27
@haraldpdl authored
Showing with 12 additions and 4 deletions.
  1. +12 −4 catalog/product_info.php
View
16 catalog/product_info.php
@@ -44,9 +44,17 @@
tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");
if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
- $products_price = '<del>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
+ $products_price = '<del>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</del> <span class="productSpecialPrice" itemprop="price">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
} else {
- $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
+ $products_price = '<span itemprop="price">' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
+ }
+
+ if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) {
+ $products_price .= '<link itemprop="availability" href="http://schema.org/PreOrder" />';
+ } elseif ((STOCK_CHECK == 'true') && ($product_info['products_quantity'] < 1)) {
+ $products_price .= '<link itemprop="availability" href="http://schema.org/OutOfStock" />';
+ } else {
+ $products_price .= '<link itemprop="availability" href="http://schema.org/InStock" />';
}
$products_name = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_info['products_id']) . '" itemprop="url"><span itemprop="name">' . $product_info['products_name'] . '</span></a>';
@@ -61,7 +69,7 @@
<div itemscope itemtype="http://schema.org/Product">
<div>
- <h1 style="float: right;" itemprop="offers" itemscope itemtype="http://schema.org/Offer"><span itemprop="price"><?php echo $products_price; ?></span></h1>
+ <h1 style="float: right;" itemprop="offers" itemscope itemtype="http://schema.org/Offer"><?php echo $products_price; ?></h1>
<h1 ><?php echo $products_name; ?></h1>
</div>
@@ -219,7 +227,7 @@
$manufacturer_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$product_info['manufacturers_id'] . "'");
if (tep_db_num_rows($manufacturer_query)) {
$manufacturer = tep_db_fetch_array($manufacturer_query);
- echo '<div itemscope itemtype="http://schema.org/Organization" style="display: none;"><span itemprop="name">' . $manufacturer['manufacturers_name'] . '</span></div>';
+ echo '<div itemprop="manufacturer" itemscope itemtype="http://schema.org/Organization" style="display: none;"><span itemprop="name">' . $manufacturer['manufacturers_name'] . '</span></div>';
}
}
?>

2 comments on commit f67201f

@acidvertigo

Excellent. It can be added also the tag as for example " meta itemprop="priceCurrency" content="EUR" / " for the currency. Sorry if i post here but i'm on tablet.

@haraldpdl
Owner

Nice! I'll get that in as well soon. I didn't know about the meta tag - would it be better to use the meta tag instead of css display:none?

Please sign in to comment.
Something went wrong with that request. Please try again.