Zen Cart Logo
Forums / Addon Templates / Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

Views: 14,146

Results 1 to 14 of 14
13 Jan 2017, 4:47 AM
#1
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

If you are using a template that incorporates the DG REVIEWS function, you can do an edit to:-

/includes/templates/your_custom_template/templates/tpl_dgReview.php

... and this will embed Google-verified REVIEWS Structured Data Markup.

(This is a reviews feature I have in PICAFLOR AZUL westminster_new - so it could be in other templates by this author.)

SEE in the code for:-

<!-- BEGIN ADDITION OF REVIEWS STRUCTURED DATA - SCHEMA.ORG -->

Then edit / replace the text through to:-

<!-- END ADDITION OF REVIEWS STRUCTURED DATA - SCHEMA.ORG -->
<?php 
// dgReviews v 1.01
//Modified to work with version v1.3.6  of the dgcart
// This is a quick down and dirty mod to add product reviews onto the product info page
// by MichaelDuvall.com
// Modified by Anne (Picaflor-Azul.com) for Winchester Responisve v. 1.0
?>
	<!-- bof: dgReviews-->
<div class="pi-reviews">
<?php
//change this constant to change the title for the customer reviews
  $review_title = 'Customer Reviews';
  
 $review_status = " and r.status = '1'";
  /* This is where you change the parameter value to output 1000 charaters or equivelent */
  $reviews_query_raw = "select r.reviews_id, left(rd.reviews_text, 1000) as reviews_text,
                               r.reviews_rating, r.date_added, r.customers_name
                        from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd
                        where r.products_id = '" . (int)$_GET['products_id'] . "'
                        and r.reviews_id = rd.reviews_id
                        and rd.languages_id = '" . (int)$_SESSION['languages_id'] . "'" .
                        $review_status . "
                        order by r.reviews_id desc";

  $reviews_split = new splitPageResults($reviews_query_raw, MAX_DISPLAY_NEW_REVIEWS);

  if ($reviews_split->number_of_rows > 0) {
    if ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3')) {
?>
  <?php 
  if ($reviews->fields['count'] > 0) {
  }
  ?>
  
  <div class="navSplitPagesResult"><?php echo $reviews_split->display_count(TEXT_DISPLAY_NUMBER_OF_REVIEWS); ?></div>
<br/>
  <div class="forward"><?php echo TEXT_RESULT_PAGE . ' ' . $reviews_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'main_page'))); ?></div>
  <br class="clearBoth" />  
 <?php
    }

    $reviews = $db->Execute($reviews_split->sql_query);

    while (!$reviews->EOF) {
?>
  <?php // change the class name here to reflect your CSS page ?>


<!-- BEGIN ADDITION OF REVIEWS STRUCTURED DATA - SCHEMA.ORG -->
<div class="pi-reviews-wrapper" itemprop="review" itemscope itemtype="http://schema.org/Review">  
<meta itemprop="itemReviewed" itemscope itemtype="http://schema.org/Product">
<meta itemprop="name" content="<?php echo $products_name; ?>">
<div class="pi-reviews-left">
<div class="review-date" itemprop="datePublished" content="<?php echo sprintf($reviews->fields['date_added']); ?>"><?php echo sprintf(zen_date_short($reviews->fields['date_added'])); ?></div>
<div class="review-name"><?php echo sprintf(zen_output_string_protected($reviews->fields['customers_name'])); ?></div>
<meta itemscope itemtype="http://schema.org/Person" itemprop="author" content="<?php echo sprintf(zen_output_string_protected($reviews->fields['customers_name'])); ?>">
<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
<meta itemprop="worstRating" content="1">
<div class="rating"><meta itemprop="ratingValue" content= "<?php echo  sprintf($reviews->fields['reviews_rating']); ?>">
<?php echo  sprintf(zen_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $reviews->fields['reviews_rating'] . '.png', sprintf(TEXT_OF_5_STARS, $reviews->fields['reviews_rating'])), sprintf(TEXT_OF_5_STARS, $reviews->fields['reviews_rating']))  . '</div><meta itemprop="bestRating" content="5"></div></div><div class="pi-reviews-right" itemprop="description"><p>' . zen_break_string(zen_output_string_protected(stripslashes($reviews->fields['reviews_text'])), 35, ''); ?></p>
</div>
<div class="clearBoth"></div></div>
<!-- END ADDITION OF REVIEWS STRUCTURED DATA - SCHEMA.ORG -->

 
<?php
      $reviews->MoveNext();
    }
?>
<?php
  } else {

echo TEXT_FIRST_REVIEW . '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, zen_get_all_get_params(array())) . '">' . TEXT_FIRST_REVIEW_WRITE . '</a>';
?>
 
<?php
  }

  if (($reviews_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>

<div id="productReviewLink" class="buttonRow"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, zen_get_all_get_params(array())) . '">' . zen_image_button(BUTTON_IMAGE_WRITE_REVIEW, BUTTON_WRITE_REVIEW_ALT) . '</a>'; ?></div>

    <div class="navSplitPagesResult"><?php echo $reviews_split->display_count(TEXT_DISPLAY_NUMBER_OF_REVIEWS); ?></div>
  <br/>
    <div><?php echo TEXT_RESULT_PAGE . ' ' . $reviews_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'main_page'))); ?></div>
 
<?php
  }
?>
</div>
<!-- eof dgreviews -->
<?php //this is the end of dgReview?>

TEST at: https://search.google.com/structured-data/testing-tool

13 Jan 2017, 2:38 PM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

Bear in mind, the structured data markup appears only when there is a review being rendered on the product info page.

(This influences Search Engines in awarding "stars" to search results - so it makes sense to include it. Research shows people are 40% more likely to click on a site if the reviews stars are good - four or more.)

14 Jan 2017, 1:19 PM
#3
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

...Now... if this could be done in json/ld it would be even better.

Hi Melanie (Prough)... perhaps you could get this into json???? :smile:

14 Jan 2017, 4:47 PM
#4
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

schoolboy:

...Now... if this could be done in json/ld it would be even better.

Hi Melanie (Prough)... perhaps you could get this into json???? :smile:
I have it ready in json I'll post the files later, as I'm am not near my pc right now .

14 Jan 2017, 6:32 PM
#5
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

See Zen-Cart-Structured-Data-using-Json
You can use the all files, or just the ones you like

17 Jan 2017, 4:39 AM
#6
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

Thanks a ton for this... Really valuable stuff - every zencart operator should install & configure... I really appreciate the work you put into this.

30 Jan 2017, 9:49 AM
#7
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

Design75:

See Zen-Cart-Structured-Data-using-Json
You can use the all files, or just the ones you like

Excellent stuff! Would be good to do all the configuration and data in the Admin at some stage.

Cheers / Frank

23 Apr 2019, 7:21 PM
#9
romancoins avatar

romancoins

New Zenner

Join Date:
Oct 2009
Posts:
21
Plugin Contributions:
0

Re: Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

Design75:

See Zen-Cart-Structured-Data-using-Json
You can use the all files, or just the ones you like

Hello all!

I installed Designs75 Json Structured Data. Thank you!

All ok except when i am running search.google.com/test/rich-results - i am getting an error from google: Parsing error: Missing ',' or '}'

The error points to the image part in jscript_structured_data_product.php

The line that generates the error is:

"image": "<?php echo (($request_type == 'SSL') ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG ) . '/' . DIR_WS_IMAGES . zen_get_products_image((int)$_GET['products_id']); ?>",

The output generated by the script is:

"image": "https://www.vapori.ro//images/<img src="bmz_cache/d/dbd47353f10d2c834f3dd24491f6bfc0.image.91x100.jpg" alt="Aramax POWER, 5000 mAh - Negru + 100 ml Lichid Gratuit" title=" Aramax POWER, 5000 mAh - Negru + 100 ml Lichid Gratuit " width="91" height="100" />",

Google structured test say that the part where "bmz_cache" starts should contain ',' or '}'

Can you please help me out with this?

Thank you in advance!
Janos

24 Apr 2019, 8:06 AM
#12
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

I searched for the error, but can not find why it is there.
Since this mod no longer developed, I recommend using this one:
https://www.zen-cart.com/showthread.php?221868-Structured-Data-Markup-for-Schema-Facebook-Open-Graph-Twitter
It is based on mine, but has been improved.

24 Apr 2019, 8:18 AM
#13
romancoins avatar

romancoins

New Zenner

Join Date:
Oct 2009
Posts:
21
Plugin Contributions:
0

Re: Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

Finally fixed it!

If any one has this problem.

Replace this:

"image": "<?php echo (($request_type == 'SSL') ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG ) . '/' . DIR_WS_IMAGES . zen_get_products_image((int)$_GET['products_id']); ?>",

With:

"image": "<?php echo $store_url . '/' . $img; ?>",

The second version generates a static url:

https://www.example.com/bmz_cache/image.jpg

And it seems that google structured test needs this.

Best regards,
Janos

27 Jun 2019, 4:31 AM
#14
gernot avatar

gernot

Zen Follower

Join Date:
Feb 2017
Location:
Tokyo, Japan
Posts:
334
Plugin Contributions:
0

Re: Strutured Data Markup for CUSTOMER PRODUCT REVIEWS - schema.org

deleted.