Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

first_name + default_city for product reviews author?


Misteraven

Recommended Posts

Hello,

 

I was digging through the archives and surprised to see there weren't any (as far as I could find) posts about changing the product review authors name from "first_name last_name" to something a little more discreet such as "first_name from default_city".

 

I'm trying to figure this one out, but I'm kind of struggling with it. Seems like it'd be done in product_reviews_write.php, but because addresses are stored in a seperate table than the rest of the info and a person can have several addresses, I'm having some trouble with it.

 

Any help will be very greatly appreciated (as always).

 

Many thanks.

Link to comment
Share on other sites

I figured it out... Here's the solution:

 

 

change:

 

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

 

to

 

$customer = tep_db_query("select c.customers_firstname, c.customers_lastname, a.entry_city from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " a where c.customers_id = '" . $customer_id . "' and a.customers_id = c.customers_id and a.address_book_id = '" . $customer_default_address_id . "'");

 

you'll need to do this in each instance in the product_review* files.

Link to comment
Share on other sites

I figured it out... Here's the solution:

 

$customer = tep_db_query("select c.customers_firstname, c.customers_lastname, a.entry_city from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " a where c.customers_id = '" . $customer_id . "' and a.customers_id = c.customers_id and a.address_book_id = '" . $customer_default_address_id . "'");

 

you'll need to do this in each instance in the product_review* files.

 

Just a thought in the interest of clarity and speed...you don't need to request the customer last name since you never use it, and since you're selecting on customer id being common to both tables, do you need to do the last compare? (a.address_book_id = . $customer_default_address_id)

 

Aodhan

Link to comment
Share on other sites

actually, I realized when editing the next page that, I need to add the entry_city to the reviews database in product_review_write.php in order to get it to show up.

 

And yes, your correct in the fact that you can drop the call for last name. I jsut did that part as well. As far as the last compare, I'm not sure. I actually based this off the code used in account.php, so I'm kinda flying by the seat of my pants here.

Link to comment
Share on other sites

actually, I realized when editing the next page that, I need to add the entry_city to the reviews database in product_review_write.php in order to get it to show up.

 

And yes, your correct in the fact that you can drop the call for last name. I jsut did that part as well. As far as the last compare, I'm not sure. I actually based this off the code used in account.php, so I'm kinda flying by the seat of my pants here.

 

I'd try it and see. It's a REALLY minor thing, but I'm in a nitpicky mood this morning :lol:

 

Aodhan

Link to comment
Share on other sites

  • 5 years later...

Ok I'm trying to do the same thing as this post. I want the reviews to be more anonymous like Greg from Pittsburgh. I've added the code from this website into by page, but nothing is posting. The product_review_write page shows "From:" and it's blank. I've pasted my code.

<?php
/*
 $Id: product_reviews_write.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

 Copyright © 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 if (!tep_session_is_registered('customer_id')) {
   $navigation->set_snapshot();
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

 $product_info_query = tep_db_query("select p.products_id, p.products_model, p.products_image, p.products_price, p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
 if (!tep_db_num_rows($product_info_query)) {
   tep_redirect(tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params(array('action'))));
 } else {
   $product_info = tep_db_fetch_array($product_info_query);
 }

$customer = tep_db_query("select c.customers_firstname, c.customers_lastname, a.entry_city from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " a where c.customers_id = '" . $customer_id . "' and a.customers_id = c.customers_id and a.address_book_id = '" . $customer_default_address_id . "'");

 if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
   $rating = tep_db_prepare_input($HTTP_POST_VARS['rating']);
   $review = tep_db_prepare_input($HTTP_POST_VARS['review']);

   $error = false;
   if (strlen($review) < REVIEW_TEXT_MIN_LENGTH) {
     $error = true;

     $messageStack->add('review', JS_REVIEW_TEXT);
   }

   if (($rating < 1) || ($rating > 5)) {
     $error = true;

     $messageStack->add('review', JS_REVIEW_RATING);
   }

   if ($error == false) {
     tep_db_query("insert into " . TABLE_REVIEWS . " (products_id, customers_id, customers_name, reviews_rating, date_added) values ('" . (int)$HTTP_GET_VARS['products_id'] . "', '" . (int)$customer_id . "', '" . tep_db_input($customer['customers_firstname']) . ' ' . tep_db_input($customer['customers_lastname']) . "','" .tep_db_input($address['entry_city']). "', '" . tep_db_input($rating) . "', now())");
     $insert_id = tep_db_insert_id();

     tep_db_query("insert into " . TABLE_REVIEWS_DESCRIPTION . " (reviews_id, languages_id, reviews_text) values ('" . (int)$insert_id . "', '" . (int)$languages_id . "', '" . tep_db_input($review) . "')");

     tep_redirect(tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params(array('action'))));
   }
 }

 /*if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
   $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
 } else {
   $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
 }*/

 if (tep_not_null($product_info['products_model'])) {
   $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
 } else {
   $products_name = $product_info['products_name'];
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_REVIEWS_WRITE);

 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript"><!--
function checkForm() {
 var error = 0;
 var error_message = "<?php echo JS_ERROR; ?>";

 var review = document.product_reviews_write.review.value;

 if (review.length < <?php echo REVIEW_TEXT_MIN_LENGTH; ?>) {
   error_message = error_message + "<?php echo JS_REVIEW_TEXT; ?>";
   error = 1;
 }

 if ((document.product_reviews_write.rating[0].checked) || (document.product_reviews_write.rating[1].checked) || (document.product_reviews_write.rating[2].checked) || (document.product_reviews_write.rating[3].checked) || (document.product_reviews_write.rating[4].checked)) {
 } else {
   error_message = error_message + "<?php echo JS_REVIEW_RATING; ?>";
   error = 1;
 }

 if (error == 1) {
   alert(error_message);
   return false;
 } else {
   return true;
 }
}

function popupWindow(url) {
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res
izable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,le
ft=150')
}
//--></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><?php echo tep_draw_form('product_reviews_write', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'action=process&products_id=' . $HTTP_GET_VARS['products_id']), 'post', 'onSubmit="return checkForm();"'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading" valign="top"><?php echo $products_name; ?></td>
           <td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
 if ($messageStack->size('review') > 0) {
?>
     <tr>
       <td><?php echo $messageStack->output('review'); ?></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
 }
?>
     <tr>
       <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
         <tr>
           <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td class="main"><?php echo '<b>' . SUB_TITLE_FROM . '</b> ' . tep_output_string_protected($customer['customers_firstname'] . ' ' . $customer['customers_lastname']); ?></td>
             </tr>
             <tr>
               <td class="main"><b><?php echo SUB_TITLE_REVIEW; ?></b></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="2" cellpadding="2">
                     <tr>
                       <td class="main"><?php echo tep_draw_textarea_field('review', 'soft', 60, 15); ?></td>
                     </tr>
                     <tr>
                       <td class="smallText" align="right"><?php echo TEXT_NO_HTML; ?></td>
                     </tr>
                     <tr>
                       <td class="main"><?php echo '<b>' . SUB_TITLE_RATING . '</b> ' . TEXT_BAD . ' ' . tep_draw_radio_field('rating', '1') . ' ' . tep_draw_radio_field('rating', '2') . ' ' . tep_draw_radio_field('rating', '3') . ' ' . tep_draw_radio_field('rating', '4') . ' ' . tep_draw_radio_field('rating', '5') . ' ' . TEXT_GOOD; ?></td>
                     </tr>
                   </table></td>
                 </tr>
               </table></td>
             </tr>
             <tr>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></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 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(array('reviews_id', 'action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
                       <td class="main" align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
                       <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                     </tr>
                   </table></td>
                 </tr>
               </table></td>
             </tr>
           </table></td>
           <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" align="right" valign="top"><table border="0" cellspacing="0" cellpadding="2">
             <tr>
               <td align="center" class="smallText">
<?php
 if (tep_not_null($product_info['products_image'])) {
?>
<script language="javascript"><!--
document.write('<?php echo '<a href="java script:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>
</noscript>
<?php
 }

 //echo '<p><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now') . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a></p>';
?>
               </td>
             </tr>
           </table>
         </td>
       </table></td>
     </tr>
   </table></form></td>
<!-- body_text_eof //-->
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
   </table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...