Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product reviews code modification not quite right


JoeWoodworker

Recommended Posts

I'd like to get Osc to show the "reviews" button in the product listing only if there is at least one review that has been written. Otherwise, I'd like it to show the "write a review" button.

 

I was given this code be a kind Osc'er but I'm not sure its right.

Any suggestions?

 

<?php if ($reviews_values['count'] >= 1 ) { echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, 'products_id=' . $product_info['products_id']) . '" target="_self"' . TEXT_CURRENT_REVIEWS_READ . '</a>';} else { echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'products_id=' . $product_info['products_id']) . '" target="_self"' . TEXT_CURRENT_REVIEWS_WRITE . '</a>';}?>

Evil will always triumph over good...

Because good is dumb.

- D.H.

Link to comment
Share on other sites

This is what I use, its located around line 165 of the product_info.php file but it may be different on yours

 

I replaced;

 

            <td class="main"><a href="<?php echo tep_href_link(FILENAME_PRODUCT_REVIEWS, substr(tep_get_all_get_params(), 0, -1)); ?>"><?php echo tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS); ?></a></td>

 

and changed it to......

 

<?php

   $reviews = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "'");

   $reviews_values = tep_db_fetch_array($reviews);

   if ($reviews_values['count'] > 0) {

?>

           <td class="main"><a href="<?php echo tep_href_link(FILENAME_PRODUCT_REVIEWS, substr(tep_get_all_get_params(), 0, -1)); ?>"><?php echo tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS); ?></a></td>

<?php

   } else {

?>

           <td class="main"><a href="<?php echo tep_href_link(FILENAME_PRODUCT_REVIEWS, substr(tep_get_all_get_params(), 0, -1)); ?>"><?php echo tep_image_button('button_write_review.gif', IMAGE_BUTTON_WRITE_REVIEW); ?></a></td>

<?php

   }

?>

 

 

Hope it helps!

 

Back up before you try!

Reddy to Rumble

 

Thank you osCommerce and all who Contribute to her!

Link to comment
Share on other sites

Cool! It worked. Thank you!

 

I did change one thing in the code though...

<?php 

   $reviews = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "'"); 

   $reviews_values = tep_db_fetch_array($reviews); 

   if ($reviews_values['count'] > 0) { 

?> 

           <td class="main"><a href="<?php echo tep_href_link(FILENAME_PRODUCT_REVIEWS, substr(tep_get_all_get_params(), 0, -1)); ?>"><?php echo tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS); ?></a></td> 

<?php 

   } else { 

?> 

           <td class="main"><a href="<?php echo tep_href_link(FILENAME_PRODUCT_REVIEWS, substr(tep_get_all_get_params(), 0, -1)); ?>"><?php echo tep_image_button('button_write_review.gif', IMAGE_BUTTON_WRITE_REVIEWS_WRITE); ?></a></td> 

<?php 

   } 

?>

 

That just changes it so it goes directly to the write a review page instead of the review page.

Evil will always triumph over good...

Because good is dumb.

- D.H.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...