I hope this is posted in the correct place on the forum..
I am trying to follow a tutorial in melanie prough's blog that is in reference to customizing Google snippets with microdata. My template code (in most cases) did not match the code in her tutorial exactly. I am posting the changes I made in hopes that I can find out what I did wrong. My attempt at adding this code was unsuccessful in that, when I used the google tools to check it, no data was found;
CHANGE #1
These changes are in includes/templates/my_template-templates/tpl_product_info_display.php
Her Instructions...
Locate your product name
<h1 id="productName"><?php echo $products_name; ?></h1>
**Now wrap it in the property name tag**
<h1 id="productName"><span itemprop="name"><?php echo $products_name; ?></span></h1>
What I actually did...
Changed this...
<h1 id="productName" class="productGeneral"><?php echo $products_name; ?></h1>
To this....
<h1 id="productName" class="productGeneral"><span itemprop="name"><?php echo $products_name; ?></span></h1>
Change #2
Her Instructions...
Locate your price
<h2 id="productPrices">
<?php
// base price
if ($show_onetime_charges_description == 'true') {
$one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />';
} else {
$one_time = '';
}
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);
?></h2>
Now we will wrap it in the price property
<h2 id="productPrices">
<?php
// base price
if ($show_onetime_charges_description == 'true') {
$one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />';
} else {
$one_time = '';
}
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . '<meta itemprop="currency" content="USD" /><span itemprop="price">' . zen_get_products_display_price((int)$_GET['products_id']) . '</span>';
?></h2>
What I actually did...
Changed this...
<h2 id="productPrices" class="productGeneral">
<?php
// base price
if ($show_onetime_charges_description == 'true') {
$one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />';
} else {
$one_time = '';
}
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);
?></h2>
To this....
<h2 id="productPrices" class="productGeneral">
<?php
// base price
if ($show_onetime_charges_description == 'true') {
$one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />';
} else {
$one_time = '';
}
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') .'<meta itemprop="currency" content="USD" /><span itemprop="price">' . zen_get_products_display_price((int)$_GET['products_id']) . '</span>';
?></h2>
Change #3
Her Instructions...
Locate your product description
<div id="productDescription"><?php echo stripslashes($products_description); ?></div>
and wrap it in the description property tag
<div id="productDescription"><span itemprop="description"><?php echo stripslashes($products_description); ?></span></div>
What I actually did...
Changed this...
<div id="productDescription" class="productGeneral biggerText"><?php echo stripslashes($products_description); ?></div>
To this....
<div id="productDescription" class="productGeneral biggerText"><span itemprop="description"><?php echo stripslashes($products_description); ?></span></div>
Change #4
Her Instructions...
Locate the manufacturer's function
<?php echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li>' . TEXT_PRODUCT_MANUFACTURER . $manufacturers_name . '</li>' : '') . "\n"; ?>
now you will wrap it in either the brand or manufacturer property tag, whichever is most appropriate for your cart
<?php echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li>' . TEXT_PRODUCT_MANUFACTURER . '<span itemprop="brand">' . $manufacturers_name . '</span></li>' : '') . "\n"; ?>
What I actually did...
Changed this...
<?php echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li><span class="product-info-label">' . TEXT_PRODUCT_MANUFACTURER . '</span>' . $manufacturers_name . '</li>' : '') . "\n"; ?>
To this....
<?php echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li><span class="product-info-label">' . TEXT_PRODUCT_MANUFACTURER . '</span>' . '<span itemprop="brand">' .$manufacturers_name . '</span></li>' : '') . "\n"; ?>
Change #5
Her Instructions...
Using the identifier model. Locate your model number line.
<?php echo (($flag_show_product_info_model == 1 and $products_model !='') ? '<li>' . TEXT_PRODUCT_MODEL . $products_model . '</li>' : '') . "\n"; ?>
Now we will wrap it in the mpn (manufacturers part number) identifier property
<?php echo (($flag_show_product_info_model == 1 and $products_model !='') ? '<li>' . TEXT_PRODUCT_MODEL . '<span itemprop="identifier" content="mpn:' . $products_model . '">' . $products_model . '</span></li>' : '') . "\n"; ?>
What I actually did...
Changed this...
<?php echo (($flag_show_product_info_model == 1 and $products_model !='') ? '<li><span class="product-info-label">' . TEXT_PRODUCT_MODEL . '</span>' . $products_model . '</li>' : '') . "\n"; ?>
To this....
<?php echo (($flag_show_product_info_model == 1 and $products_model !='') ? '<li><span class="product-info-label">' . TEXT_PRODUCT_MODEL . '</span>' . '<span itemprop="identifier" content="mpn:' . $products_model . '">' . $products_model . '</span></li>' : '') . "\n"; ?>
Change #6
Her Instructions..
Using the quantity identifier. Locate your quantity line.
<?php echo (($flag_show_product_info_quantity == 1) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>' : '') . "\n"; ?>
Now we will wrap it in the quantity property
<?php echo (($flag_show_product_info_quantity == 1) ? '<li>' . '<span itemprop="quantity">' . $products_quantity . '</span>' . TEXT_PRODUCT_QUANTITY . '</li>' : '') . "\n"; ?>
What I actually did...
Changed this...
<?php echo (($flag_show_product_info_quantity == 1) ? '<li><span class="product-info-label">'. TEXT_PRODUCT_QUANTITY . ': </span>' . $products_quantity . '</li>' : '') . "\n"; ?>
To this....
<?php echo (($flag_show_product_info_quantity == 1) ? '<li><span class="product-info-label">'. TEXT_PRODUCT_QUANTITY . ': </span>' . '<span itemprop="quantity">' .$products_quantity . '</span>' .'</li>' : '') . "\n"; ?>
Change #7
Her Instructions..
Using the Availability property
Just a quick way to dynamically deliver the value of in stock our not from quantity.
In the list you just edited for model and such locate the closing </ul> tag and on the line right above it add the following. Acceptable values are (in_stock, out_of_stock, instore_only or preorder)
<?php if ($products_quantity > 0) { ?><li><span itemprop="availability" content="in_stock">In Stock</span></li><?php }?><?php if ($products_quantity == 0) { ?><li><span itemprop="availability" content="out_of_stock">Out of Stock</span></li><?php }?>
Here is what I added
***the last bit of code before the closing </ul> tag was..................
..................TEXT_PRODUCT_MANUFACTURER . '</span>' . '<span itemprop="brand">' .$manufacturers_name . '</span></li>' : '') . "\n"; ?>
<?php if ($products_quantity > 0) { ?><li><span itemprop="availability" content="in_stock">In Stock</span></li><?php }?><?php if ($products_quantity == 0) { ?><li><span itemprop="availability" content="out_of_stock">Out of Stock</span></li><?php }?>
</ul>
Change #8
Her Instructions..
Using the Condition property
We will fake this for a vanilla Zen Cart as well by adding another line just above the closing </ul> as in the previous instruction. Values which can be used are (new, used and refurbished)
<li><span itemprop="condition" content="new">New</span></li>
So change #7 now looks like this...
<?php if ($products_quantity > 0) { ?><li><span itemprop="availability" content="in_stock">In Stock</span></li><?php }?><?php if ($products_quantity == 0) { ?><li><span itemprop="availability" content="out_of_stock">Out of Stock</span></li><?php }?>
<li><span itemprop="condition" content="new">New</span></li>
</ul>
Change #9
Lastly to make this markup most flexible for search engines and other platforms to understand locate the opening div for your product content in tpl_product_info_display.php
Using Rich Snippets to identify the category
the section marked details, find
</ul>
<br />
<?php
}
?>
<!--eof Product details list -->
Just before this line add
<li>Category: <?php echo '<span itemprop="category" content="' . $categories->fields['categories_name'] . '">' . $categories->fields['categories_name'] ; ?></li>
Mine looked different, so I changed this.....
</ul>
<br class="clearBoth" />
<?php
}
?>
<!--eof Product details list -->
To this....
<br class="clearBoth" />
<?php
}
?>
<li>Category: <?php echo '<span itemprop="category" content="' . $categories->fields['categories_name'] . '">' . $categories->fields['categories_name'] ; ?></li>
<!--eof Product details list -->
Change #10
Her Instructions..
Find
<div id="productGeneral">
and add this to it
itemscope itemtype="http://data-vocabulary.org/Product"
So it looks like this
<div id="productGeneral" itemscope itemtype="http://data-vocabulary.org/Product">
This is all I could find with id="productGeneral", It was on line 16 in my css.. so I changed this
<div class="centerColumn" id="productGeneral">
To this...
<div class="centerColumn" id="productGeneral" itemscope itemtype="http://data-vocabulary.org/Product">
All other changes that I made were exact matches to her 'original' code, and so I am not worried about them. Thanks!!