You are here:  » Additional review/rating by Admin


Additional review/rating by Admin

Submitted by richard on Mon, 2016-06-20 14:41 in

Hi David,

In addition to consumer reviews I would like to add an "admin review" for a product. Initially I thought I could adapt http://www.pricetapestry.com/node/3633 but this would not allow for filtering or sorting.

How would I duplicate the current review functionality?

Best regards,

Richard

Submitted by support on Tue, 2016-06-21 10:52

Hello Richard,

It would be straight forward to add a "house" review flag to the reviews table, set via a checkbox during review moderation, and then have the reviews page promote house reviews to the top, followed by visitor reviews ordered by created date as normal. To give this a go, first run the following dbmod.php script (from top level) to add the `house` flag to the `reviews` table:

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."reviews`
            ADD `house` INT(11) NOT NULL default '0'"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Next, edit admin/moderate.php and look for the following code at line 16:

$sql = "UPDATE `".$config_databaseTablePrefix."reviews` SET comments='".database_safe($_POST["comments"])."',approved='".time()."' WHERE id='".$_POST["id"]."'";

...and REPLACE with:

$sql = "UPDATE `".$config_databaseTablePrefix."reviews` SET comments='".database_safe($_POST["comments"])."',approved='".time()."',house='".(isset($_POST["house"])?"1":"")."' WHERE id='".$_POST["id"]."'";

And then the following code at line 79:

  widget_textArea("Comments","comments",FALSE,$review["comments"],200,6);

...and REPLACE with:

  widget_textArea("Comments","comments",FALSE,$review["comments"],200,6);
  widget_checkBox("House Review?","house",FALSE,FALSE);

To change the selection order, edit reviews.php and look for the following code at line 66:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."reviews` WHERE product_name = '".database_safe($q)."' AND approved <> '0' ORDER BY created";

...and REPLACE with:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."reviews` WHERE product_name = '".database_safe($q)."' AND approved <> '0' ORDER BY house DESC,created";

And finally to highlight house reviews with a prefix e.g. "Our Review:" or as required, edit html/ratings.php and look for the following code at line 11:

  <?php if ($review["comments"]): ?>

...and REPLACE with:

  <?php if ($review["house"]): ?><strong>Our Review:</strong> <?php endif; ?>
  <?php if ($review["comments"]): ?>

Cheers,
David.
--
PriceTapestry.com

Submitted by richard on Wed, 2016-06-22 13:25

Hi David,

A very elegant solution! Thank you.

Best regards,

Richard

Submitted by richard on Wed, 2016-06-22 14:39

Hi David

I would like to also access the house review from the search results. How can I access the review table from search results table?

Thanks again for all your help.

Richard

Submitted by support on Wed, 2016-06-22 15:19

Hi Richard,

Sure - to display the house review, for example, below the description, edit html/searchresults.php and look for the following code at line 65:

  <?php endif; ?>

...and REPLACE with:

  <?php endif; ?>
  <?php
    if ($product["rating"])
    {
      $sql = "SELECT * FROM `".$config_databaseTablePrefix."reviews`
                WHERE product_name = '".database_safe($product["normalised_name"])."' AND house='1' LIMIT 1";
      if (database_querySelect($sql,$reviews))
      {
        $review = $reviews[0];
        print "<p><strong>Our Review:</strong> ".$review["comments"]."</p>";
      }
    }
  ?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by richard on Wed, 2016-06-22 15:35

Thanks David,

Just what I needed :)

Submitted by Rocket32 on Thu, 2017-05-11 21:50

Hello David. Does this same house review modification works with a the product page with the reviews combined? I also am looking to create a similar reviews page for certain products? Possibly a house reviews directory of a few products with a 500 to 800 word review on a product. Also are customer reviews limited to the number of words allowed in their review if so how to adjust this number? Also can reviews also work on Amazon or Ebay products?

Submitted by support on Fri, 2017-05-12 07:19

Hi,

As mods would be required in a couple of places in your combined product / reviews page, please could you email me the products.php file from this installation and I'll point you in the right direction...

Cheers,
David.
--
PriceTapestry.com

Submitted by Antony on Thu, 2020-09-24 06:20

Morning David,

I am very interested in the above; can these modifications be applied to 18/06A?

One other thing I would want to ask is if there is a simple way of setting a default rating value (let's say 3 stars) for all registered products by modifying the database default values.

I've considered overwriting the 0, 1 and 2.gif which does the job at first glance but this would result in a permanent rating of 3 regardless lower actual rated products by visitors.

Thanks

Antony

Submitted by support on Thu, 2020-09-24 09:18

Hi Antony,

The above is current for 18/06A.

To set a default rating of 3, edit includes/admin.php and look for the following code at line 750:

    $sql = "UPDATE `".$config_databaseTablePrefix."products` SET rating='0',reviews='0'";

...and REPLACE with:

    $sql = "UPDATE `".$config_databaseTablePrefix."products` SET rating='3',reviews='0'";

Cheers,
David.
--
PriceTapestry.com

Submitted by Antony on Thu, 2020-09-24 09:35

Amazing thanks!

Submitted by safari45 on Fri, 2020-09-25 10:58

Hi David, I hope you are doing great today.

- With regards to review section, is it possible to add name of the reviewer. Currrently there is comment, rate but no username/reviewer

- Will merchant review be available in the next release?

Submitted by support on Sat, 2020-09-26 09:36

Hi,

A name field can be added easily - first, create and run the following dbmod.php script from the top level of your Price Tapestry installation to add the new field:

<?php
  set_time_limit
(0);
  require(
"includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."reviews`
            ADD `name` varchar(255) NOT NULL default ''"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Edit html/ratings.php and look for the following code at line 23:

          <?php print tapestry_stars($review["rating"],""); ?>

...and REPLACE with:

          <?php print tapestry_stars($review["rating"],""); ?>
          <?php if ($review["name"]) print "<i>by</i> ".$review["name"]; ?>

And then the following code at line 47:

              <textarea name='comments' placeholder='<?php print translate("Your Comments (optional)"); ?>'></textarea>

...and REPLACE with:

              <input type='text' name='name' placeholder='Your Name' />
              <textarea name='comments' placeholder='<?php print translate("Your Comments (optional)"); ?>'></textarea>

Edit reviews.php and look for the following code at line 14:

      $sql = "INSERT INTO `".$config_databaseTablePrefix."reviews` SET created='".time()."',approved='0',product_name='".database_safe($q)."',rating='".database_safe($_POST["rating"])."',comments='".database_safe(stripslashes(trim($_POST["comments"])))."'";

...and REPLACE with:

      $sql = "INSERT INTO `".$config_databaseTablePrefix."reviews` SET created='".time()."',approved='0',product_name='".database_safe($q)."',rating='".database_safe($_POST["rating"])."',comments='".database_safe(stripslashes(trim($_POST["comments"])))."',name='".database_safe(stripslashes(trim($_POST["name"])))."'";

Edit html/moderate.php and look for the following code at line 16:

      $sql = "UPDATE `".$config_databaseTablePrefix."reviews` SET comments='".database_safe($_POST["comments"])."',approved='".time()."' WHERE id='".$_POST["id"]."'";

...and REPLACE with:

      $sql = "UPDATE `".$config_databaseTablePrefix."reviews` SET comments='".database_safe($_POST["comments"])."',approved='".time()."' WHERE id='".$_POST["id"]."'";

And then the following code at line 79:

    widget_textArea("Comments","comments",FALSE,$review["comments"],200,6);

...and REPLACE with:

    widget_textBox("Name","name",FALSE,$review["name"]);
    widget_textArea("Comments","comments",FALSE,$review["comments"],200,6);

Cheers,
David.
--
PriceTapestry.com