Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Changing displayed information when a customer reviews a product


st-anger

Recommended Posts

Hi

 

On my site I want to adjust the display of how a customers name shows when they review a product

 

I want to only display their first name

 

is there an easy way to do this?

 

thanks in advance for any help

Link to comment
Share on other sites

Sure just comment the relevant code on the Reviews pages,

If you not too sure get back and i will have a go

Nic

 

Hi

 

Thanks for the speedy responce, I had a look at the db structure for the reviews and saw a field called "customers_name" which by the looks of it seems to be created from "Product_reviews_write.php" which seems to be created from line 27 of the file

"$customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");"

 

I tried removing the following data (in quotes) ", customers_lastname" and uploaded the modded file which came back with a php error

 

having a greater look at "product_reviews_write.php" would I also need to mod line 154?

 

having a look at "product_reviews.php" the data written comes from the field "customers_name" from the database table, so in theory I can see that I need to change what is written to the "customers_name" field but I'm not 100% sure how to go about it

 

Nick

Link to comment
Share on other sites

An alternate approach....

 

I haven't actually tried this, but I think it will work.

 

The code in product_reviews.php that displays the name:

 

					<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $product_info['products_id'] . '&reviews_id=' . $reviews['reviews_id']) . '"><u><b>' . sprintf(TEXT_REVIEW_BY, tep_output_string_protected($reviews['customers_name'])) . '</b></u></a>'; ?></td>

Change it to:

 

<?php
$parts = explode(" ", $reviews['customers_name']);
?>
				<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $product_info['products_id'] . '&reviews_id=' . $reviews['reviews_id']) . '"><u><b>' . sprintf(TEXT_REVIEW_BY, tep_output_string_protected($parts[0])) . '</b></u></a>'; ?></td>

As always it's a good idea to make a backup of any file before making any edits.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

An alternate approach....

 

I haven't actually tried this, but I think it will work.

 

The code in product_reviews.php that displays the name:

 

					<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $product_info['products_id'] . '&reviews_id=' . $reviews['reviews_id']) . '"><u><b>' . sprintf(TEXT_REVIEW_BY, tep_output_string_protected($reviews['customers_name'])) . '</b></u></a>'; ?></td>

Change it to:

 

<?php
$parts = explode(" ", $reviews['customers_name']);
?>
				<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $product_info['products_id'] . '&reviews_id=' . $reviews['reviews_id']) . '"><u><b>' . sprintf(TEXT_REVIEW_BY, tep_output_string_protected($parts[0])) . '</b></u></a>'; ?></td>

As always it's a good idea to make a backup of any file before making any edits.

 

works a treat

 

Thank You

 

Nick

Link to comment
Share on other sites

In reviews.php find this code:

 

				<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $reviews['products_id'] . '&reviews_id=' . $reviews['reviews_id']) . '"><u><b>' . $reviews['products_name'] . '</b></u></a> <span class="smallText">' . sprintf(TEXT_REVIEW_BY, tep_output_string_protected($reviews['customers_name'])) . '</span>'; ?></td>

Replace it with:

 

<?php
$parts = explode(" ", $reviews['customers_name']);
?>
			<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $reviews['products_id'] . '&reviews_id=' . $reviews['reviews_id']) . '"><u><b>' . $reviews['products_name'] . '</b></u></a> <span class="smallText">' . sprintf(TEXT_REVIEW_BY, tep_output_string_protected($parts[0])) . '</span>'; ?></td>

BACKUP FIRST!

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...