Guest Posted October 8, 2008 Share Posted October 8, 2008 Is there a way to implement the product reviews form to be displayed directly on the product_info page as opposed to going to another page. I belive it would make it for users to leave reviews. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 8, 2008 Share Posted October 8, 2008 (edited) It seems the problem has been discussed already here http://www.oscommerce.com/forums/lofiversion/i...hp?t107750.html I tried to implemented myself but I had the same problem as SwissChris The from button to continue (submit) does add the product into the basket, instead of submitting a review. What could the problem be ? Anyone more experienced? Thanks Plamen Edited October 8, 2008 by plamenski Quote Link to comment Share on other sites More sharing options...
Guest Posted October 9, 2008 Share Posted October 9, 2008 bump Quote Link to comment Share on other sites More sharing options...
Guest Posted October 9, 2008 Share Posted October 9, 2008 Aha, will try that. Thanks Quote Link to comment Share on other sites More sharing options...
Guest Posted October 9, 2008 Share Posted October 9, 2008 (edited) Thanks very much burt. It worked! ;) For those that want to implement it too. 1. On product_info.php find $product_info = tep_db_fetch_array($product_info_query); And place this code after it. $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_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); $customer = tep_db_fetch_array($customer_query); 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($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_INFO, 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); 2. I have reviews also displayed on the same page, so after the reviews or find another suitable place, place this code <?php echo tep_draw_form('product_reviews_write', tep_href_link(FILENAME_PRODUCT_INFO, 'action=process&products_id=' . $HTTP_GET_VARS['products_id']), 'post', 'onSubmit="return checkForm();"'); ?><table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td class="main" height="20"><b>Use the form below to write a review.</b></td> </tr> <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> <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" align="right"><?php echo tep_image_submit('button_continue1.gif', IMAGE_BUTTON_CONTINUE); ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table> </form> 3. Add the javascript validating the form <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,l e ft=150') } //--></script> 4. IMPORTANT. As burt noticed, make sure for form closing tag </form> for adding the products to the shopping cart is before the opening <form> tag for the posting the review form. That's it! Edited October 9, 2008 by plamenski Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.