Jump to content
Sign in to follow this  
PopTheTop

Reviews in Product Display v2.0

Recommended Posts

I would like to use the old 'Customer Review Image' contribution together with this Reviews in Product Display 2.3 contribution. I've got the Reviews in Product Display 2.3 work perfect together with the Review Approval and Allow Guest Reviews contribution. Could somebody please help me how to ad the following lines to the lines used for the Reviews in Product Display 2.3 contribution?

Below the code that normally has to come in catalog/product_reviews.php

 

// BOF Review Images
 $reviews_query_raw = "select r.reviews_id, left(rd.reviews_text, 100) as reviews_text, r.reviews_rating, r.date_added, r.customers_name, ri.reviews_image from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd left join " . TABLE_REVIEWS_IMAGES . " ri on r.reviews_id = ri.reviews_id and ri.reviews_status = '1' where r.products_id = '" . (int)$product_info['products_id'] . "' and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' and r.approved = '1' order by r.reviews_id desc";
// EOF Review Images

<?php
// BOF Review Images
?>
					<td valign="top" class="main"><?php echo (tep_not_null($reviews['reviews_image']) ? tep_image(DIR_WS_REVIEWS . $reviews['reviews_image'], $products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5" align="left"') : '') . tep_break_string(tep_output_string_protected($reviews['reviews_text']), 60, '-<br>') . ((strlen($reviews['reviews_text']) >= 100) ? '..' : '') . '<br><br><i>' . sprintf(TEXT_REVIEW_RATING, tep_image(DIR_WS_IMAGES  . 'stars_' . $reviews['reviews_rating'] . '.gif', sprintf(TEXT_OF_5_STARS, $reviews['reviews_rating'])), sprintf(TEXT_OF_5_STARS, $reviews['reviews_rating'])) . '</i>'; ?></td>
<?php
// EOF Review Images
?>

I gues I have to combine the above code with the code below(?) from product_info.php but have no idea how :huh: ..

<?php
// BEGIN PopTheTop Product Info Reviews
?>

<?php
	  $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
	  $reviews = tep_db_fetch_array($reviews_query);
	  $reviews_query_average = tep_db_query("select (avg(reviews_rating)) as average_rating from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and approved = 1");
	  $reviews_average = tep_db_fetch_array($reviews_query_average);
	  $reveiws_stars = $reviews_average['average_rating'];
	  $reveiws_rating = number_format($reveiws_stars,0);
?>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '45'); ?></td>
  </tr>
<?php
if (MAX_REVIEWS_IN_PRODUCT_INFO > 0) {
 $reviews_query = tep_db_query("select r.reviews_id, rd.reviews_text, r.reviews_rating, r.date_added, r.customers_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and rd.reviews_id = r.reviews_id and rd.languages_id = '" . $languages_id . "' and r.approved = '1' order by r.reviews_id DESC");
 $num_rows = tep_db_num_rows($reviews_query);
?>
  <tr>
	<td>
	  <table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageReviewHeading" valign="top"><?php echo BOX_HEADING_REVIEWS; ?></td>
	  </tr>
	</table>
	  </td>
  </tr>
<?php
 if ($num_rows > 0) {
$row = 0;
while (($reviews_values = tep_db_fetch_array($reviews_query)) && ($row < MAX_REVIEWS_IN_PRODUCT_INFO)) {
  $row++;
  $date_added = tep_date_short($reviews_values['date_added']);
	// Write product reviews
?>
<?php
// END PopTheTop Product Info Reviews
?>

I really hope someone could help me out with this one!!

Share this post


Link to post
Share on other sites

Friends, I have the following problem on the next screen that appears when you submit a comment:

The page loads, but this error is shown where you see the product, ie loads the top and sides, but the middle is this:

 

 

Warning: Missing argument 2 for splitPageResults::splitPageResults(), called in /home/estancia/public_html/os/product_reviews.php on line 83 and defined in /home/estancia/public_html/os/includes/classes/split_page_results.php on line 17

 

Warning: Division by zero in /home/estancia/public_html/os/includes/classes/split_page_results.php on line 59

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-0,' at line 1

 

select r.reviews_id, left(rd.reviews_text, 100) as reviews_text, r.reviews_rating, r.date_added, r.customers_name from reviews r, reviews_description rd where r.products_id = '581' and r.reviews_id = rd.reviews_id and rd.languages_id = '1' order by r.reviews_id desc limit -0,

 

[TEP STOP]

 

How not know much about programming, could someone give me a help to resolve the issue?

 

Thanks!

(I'm using google translator)

Share this post


Link to post
Share on other sites

I just downloaded version 2.3 of this module.. I wanted to know if it will work with osCommerce version greater than 2.3? It looks great on the test site.

Share this post


Link to post
Share on other sites

This has some serious table formatting issues as delivered. The reviews were in a narrow column to the far left of the screen. It looked silly because it made the page super long if the review was even moderate in length. I'm no php super-coder but I reformatted it for a better appearance. Now it stretches the review text out across the screen. There are a couple other minor appearance changes as well.

 

Instead of using the code from v2.3 in catalog/product_info.php you should do this instead. In catalog/product_info.php, where you find:

 

		    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		    <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
		    <td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
		    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

 

Replace it with:

// BEGIN PopTheTop Product Info Reviews
// Deleted 4 lines of code and replaced them with the following
?>
  <TD ALIGN="left" VALIGN="middle" CLASS="main">
<?php
 if (MAX_REVIEWS_IN_PRODUCT_INFO == '0') {
   echo tep_draw_separator('pixel_trans.gif', '100', '2') . '<br><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>    ';
 }
   if (tep_session_is_registered('customer_id')) {
  $product_notification_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and customers_id = '" . (int)$customer_id . "'");
  $check = tep_db_fetch_array($product_notification_query);
  $notification_exists = (($check['count'] > 0) ? true : false);
   } else {
  $notification_exists = false;
   }
   if ($notification_exists == true) {
  echo '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify_remove', $request_type) . '">' . tep_image_button('button_remove_notifications.gif', IMAGE_BUTTON_REMOVE_NOTIFICATIONS) . '</a>';
   } else {
  echo '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . tep_image_button('button_notifications.gif', IMAGE_BUTTON_NOTIFICATIONS) . '</a>';
   }
?>
</TD>
   <td width="80%"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		    <TD ALIGN="right" VALIGN="middle" CLASS="main"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'width="120" height="22"'); ?></TD>
		    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>


	  </tr>


<?php
   $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
   $reviews = tep_db_fetch_array($reviews_query);
   $reviews_query_average = tep_db_query("select (avg(reviews_rating)) as average_rating from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
   $reviews_average = tep_db_fetch_array($reviews_query_average);
   $reveiws_stars = $reviews_average['average_rating'];
   $reveiws_rating = number_format($reveiws_stars,0);
?>
  <tr>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '45'); ?></td>
  </tr>
<?php
if (MAX_REVIEWS_IN_PRODUCT_INFO > 0) {
 $reviews_query = tep_db_query("select r.reviews_id, rd.reviews_text, r.reviews_rating, r.date_added, r.customers_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and rd.reviews_id = r.reviews_id and rd.languages_id = '" . $languages_id . "' order by r.reviews_id DESC");
 $num_rows = tep_db_num_rows($reviews_query);
?>
  <tr>
 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
    <td><?php echo BOX_HEADING_REVIEWS; ?>
   </td>
  </tr>
<?php
 if ($num_rows > 0) {
   $row = 0;
   while (($reviews_values = tep_db_fetch_array($reviews_query)) && ($row < MAX_REVIEWS_IN_PRODUCT_INFO)) {
  $row++;
  $date_added = tep_date_short($reviews_values['date_added']);
?>
<?php
// Write product reviews
?>
  <tr>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

   <td>
  <table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
   <tr class="infoBoxContents">
 <td valign="top" class="main"><?php echo '<FONT COLOR="#006699"><b>Submited By:</b> ' . $reviews_values['customers_name'] . ' on <span class="smallText">' . $date_added . '</span></font><br>' . tep_break_string(nl2br(tep_output_string_protected($reviews_values['reviews_text'])), 60, '-<br>') . '<br><br>' . sprintf(tep_image(DIR_WS_IMAGES . 'stars_' . $reviews_values['reviews_rating'] . '.gif', sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $reviews_values['reviews_rating']))) ?>
 </td>
   </tr>
  </table>
 </td>
  </tr>
<?php
   } // END while (($reviews_values...
?>
  <tr>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '15'); ?></td>
  </tr>
  <tr>
   <TD ALIGN="left" VALIGN="middle" CLASS="main">
<?php
   if ($num_rows > MAX_REVIEWS_IN_PRODUCT_INFO) {
 echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_image_button('button_more_reviews.gif', IMAGE_BUTTON_MORE_REVIEWS) . '</a></td>';
 echo '	   <TD ALIGN="right" VALIGN="middle" CLASS="main"><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_image_button('button_write_review.gif', IMAGE_BUTTON_WRITE_REVIEW) . '</a></td>';
 echo '	   <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';
 } else {
 echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_image_button('button_write_review.gif', IMAGE_BUTTON_WRITE_REVIEW) . '</a></td>';
 }
?>
  </tr>
  <tr>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
  </tr>
<?php
   if ($reviews['count'] > 0) {
?>
  <tr>
   <td class="smallText">
   <table width="100%">
   <tr>
 <td align="left" class="smallText"><FONT COLOR="#006699"><?php echo TEXT_REVIEW_AVERAGE . ': ' . tep_image(DIR_WS_IMAGES . 'stars_' . $reveiws_rating . '.gif', '', 60, 12, 'align=absmiddle') . '</a>'; ?></font></td>
 <td align="right" class="smallText"><FONT COLOR="#006699"><?php echo sprintf(TEXT_DISPLAY_NUMBER_OF_REVIEWS_PRODUCT_INFO, $row, $num_rows); ?></font></td>
   </tr>
  </table>
  </td>
 </tr>
<?php
   } else {
?>
  <tr>
    <td class="smallText"><FONT COLOR="#006699"><?php echo sprintf(TEXT_DISPLAY_NUMBER_OF_REVIEWS_PRODUCT_INFO, $row, $num_rows); ?></font></td>
  </tr>
<?php
   }
?>
<?php
   } else { // if ($num_rows < 0)...
?>
  <tr>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
  </tr>
  <tr>
   <td>
  <table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
   <tr class="infoBoxContents">
 <td>
 <table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
   <td valign="top" class="main"><?php echo TEXT_NO_REVIEWS . '<br><br>	 <a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_image_button('button_write_review.gif', IMAGE_BUTTON_WRITE_REVIEW) . '</a>'; ?></td>
  </tr>
 </table>
 </td>
   </tr>
  </table>
  </td>
  </tr>
<?php
 }
}
// END PopTheTop Product Info Reviews

 

Notice you are getting rid of 4 lines of code now instead of 3.

 

Follow the install instructions for all other changes. If I have time I will update the contrib.

 

By the way, we also have Review Rating in Product Listing v1.2 installed and they play nicely with each other. I didn't have to make any changes to it to install this or vice versa.

 

Enjoy!

 

-Kevin


Add-Ons personally installed:

Step by Step Manual Order -- Request Reviews -- Reviews in Product Listing -- Reviews in Product Display -- Review Approval System -- Leverage Browser Cache --
Header Tag Controller -- Multilayer SEO Pop Out Menu -- Follow Us Box -- View All Products -- USPS Shipping Labels -- UPS Shipping Labels -- Monthly Sales/Tax Report --
htacess Optimisation -- Remove Unused Images -- Master Password -- Admin Change Customer Password -- Database Backup Manager -- Zero Stock Report --
Searchbox Search In Descriptions -- Easy Populate 2.76i -- Barcode Rendering -- Admin Sort By Model -- Products Purchased Report

Add-Ons personally developed:

Search for email address, etc in Orders -- Discontinue Product

Add-Ons installed by others:

View Counter -- Site Monitor -- Image Thumbnailer -- Database Optimizer -- Recaptcha -- Discount Coupons -- Add More Fields

Share this post


Link to post
Share on other sites

There is one button that doesn't show up unless you have more than 3 reviews for a product. We didn't have anything with more than 3 reviews, so I didn't see it. Anyway, it was out of position, so I made one small change to move it. About two thirds of the way down in the code above you will find:

 

 echo '		   <TD ALIGN="right" VALIGN="middle" CLASS="main"><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_image_button('button_write_review.gif', IMAGE_BUTTON_WRITE_REVIEW) . '</a></td>';
 echo '		   <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';

 

Simply reverse the order of those two lines to read:

 

  echo '	   <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';
  echo '	   <TD ALIGN="right" VALIGN="middle" CLASS="main"><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_image_button('button_write_review.gif', IMAGE_BUTTON_WRITE_REVIEW) . '</a></td>';

 

When combined with the revised products_info.php code from my previous post, you will find the buttons appear in the four corners of the box, the reviews are centered and stretched out across most of the box and the box that appeared around the Write Review button is gone.

 

FYI - Our shop is 2.2 and these appearance changes were tested in Firefox and IE.


Add-Ons personally installed:

Step by Step Manual Order -- Request Reviews -- Reviews in Product Listing -- Reviews in Product Display -- Review Approval System -- Leverage Browser Cache --
Header Tag Controller -- Multilayer SEO Pop Out Menu -- Follow Us Box -- View All Products -- USPS Shipping Labels -- UPS Shipping Labels -- Monthly Sales/Tax Report --
htacess Optimisation -- Remove Unused Images -- Master Password -- Admin Change Customer Password -- Database Backup Manager -- Zero Stock Report --
Searchbox Search In Descriptions -- Easy Populate 2.76i -- Barcode Rendering -- Admin Sort By Model -- Products Purchased Report

Add-Ons personally developed:

Search for email address, etc in Orders -- Discontinue Product

Add-Ons installed by others:

View Counter -- Site Monitor -- Image Thumbnailer -- Database Optimizer -- Recaptcha -- Discount Coupons -- Add More Fields

Share this post


Link to post
Share on other sites

I forgot the opening <?php and the closing ?> around the entire block of code. I'm just going to revise the install instructions and post a new version of the contrib, so look for it in the Add Ons section...


Add-Ons personally installed:

Step by Step Manual Order -- Request Reviews -- Reviews in Product Listing -- Reviews in Product Display -- Review Approval System -- Leverage Browser Cache --
Header Tag Controller -- Multilayer SEO Pop Out Menu -- Follow Us Box -- View All Products -- USPS Shipping Labels -- UPS Shipping Labels -- Monthly Sales/Tax Report --
htacess Optimisation -- Remove Unused Images -- Master Password -- Admin Change Customer Password -- Database Backup Manager -- Zero Stock Report --
Searchbox Search In Descriptions -- Easy Populate 2.76i -- Barcode Rendering -- Admin Sort By Model -- Products Purchased Report

Add-Ons personally developed:

Search for email address, etc in Orders -- Discontinue Product

Add-Ons installed by others:

View Counter -- Site Monitor -- Image Thumbnailer -- Database Optimizer -- Recaptcha -- Discount Coupons -- Add More Fields

Share this post


Link to post
Share on other sites

Hi,

 

Let me know if I am posting this question in the wrong string. I am looking to find a script to validate product write review so that:

 

1) only customers that purchased that product can review it

2) only allow one review regardless of how many times that customer purchased the same product

3) only allow the review after a certain number of days - so say 3 days after status is changed to "delivered"

 

Has anyone come across anything like that before? I'm semi-technical and can modify a script. I have MS2.2

 

The purpose is to avoid fake reviews and people only registering to review products they have not bought.

 

Please let me know, thanks.


osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×