Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to open reviews so every language sees them


SGershon

Recommended Posts

Hello.

I'll try to make this very clear, so anyone can follow. ;)

 

I have a site that works with more than one language.

My languages are close, or my clients understand both languages.

 

When reviews are post on one language, the other languages could not see it.

Worse than that, the products page would say: "Current Reviews: 1", but when clicking "Reviews", there was the "There are currently no product reviews" message.

 

I saw in the *.pdf that the table "reviews" is linked to the table "languages" through the "reviews_description" table.

As in:

[reviews].reviews_id = [reviews_description].reviews_id

[revies_description].language_id = [languages].language_id

 

I wanted to bypass the language limitation. Both in the "product_review" page and in the "reviews" infobox.

 

1) This is a listing from catalog/products_review, about line 80:

$reviews_query_raw = "select r.reviews_id, left(rd.reviews_text, 100) as reviews_text, r.reviews_rating, r.date_added, r.customers_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . (int)$product_info['products_id'] . "' and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' order by r.reviews_id desc";

Change it to:

$reviews_query_raw = "select r.reviews_id, left(rd.reviews_text, 100) as reviews_text, r.reviews_rating, r.date_added, r.customers_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . (int)$product_info['products_id'] . "' and r.reviews_id = rd.reviews_id order by r.reviews_id desc";

 

2) This is a listing from catalog/includes/boxes/reviews.php about line 20:

$random_select = "select r.reviews_id, r.reviews_rating, p.products_id, p.products_image, pd.products_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = r.products_id and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'";

Change it to:

$random_select = "select r.reviews_id, r.reviews_rating, p.products_id, p.products_image, pd.products_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = r.products_id and r.reviews_id = rd.reviews_id and p.products_id = pd.products_id";

 

3) This is a listing from catalog/includes/boxes/reviews.php about line 30:

$review_query = tep_db_query("select substring(reviews_text, 1, 60) as reviews_text from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$random_product['reviews_id'] . "' and languages_id = '" . (int)$languages_id . "'");

Change it to:

$review_query = tep_db_query("select substring(reviews_text, 1, 60) as reviews_text from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$random_product['reviews_id'] . "'");

 

Notes:

- Remember to backup your files before changing.

- If you use very diferent languages, this can make your clients angry.

- If your languages use different encodings, your reviews will look ugly.

 

SGershon

 

PD> In the future, I'll make a note on the reviews page that tells the client which language the review is. If someone do this before, please post it here.

PD> Please report errors.

If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Link to comment
Share on other sites

  • 2 weeks later...

Ok.

 

As promised, here's how to tell your visitor in which language the review was posted.

 

In your includes/languages/[Your Languages Here]/product_reviews.php, add a definition like this:

define('TEXT_THIS_REVIEW_LANGUAGE', 'This review was written in %s');

 

In your catalog/product_reviews.php, where we replaced the query in the previous post (around line 80), you should now use:

  $reviews_query_raw = "select r.reviews_id, left(rd.reviews_text, 100) as reviews_text, r.reviews_rating, r.date_added, r.customers_name, lang.name as langname, lang.directory as langdir, lang.image as langimg from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, " . TABLE_LANGUAGES . " lang where r.products_id = '" . (int)$product_info['products_id'] . "' and r.reviews_id = rd.reviews_id and rd.languages_id = lang.languages_id order by r.reviews_id desc";

 

Then, about line 115 of the same file, where you see:

                  <tr>

                    <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>

                    <td class="smallText" align="right"><?php echo sprintf(TEXT_REVIEW_DATE_ADDED, tep_date_long($reviews['date_added'])); ?></td>

                  </tr>

Replace with:

                  <tr>

                    <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>

<!-- LANGUAGE_LESS REVIEWS MODIFICATION! THIS NEXT <TD> -->

<td class="smallText" align="center"><?php echo sprintf(TEXT_THIS_REVIEW_LANGUAGE,

tep_image(DIR_WS_LANGUAGES .  $reviews['langdir'] . '/images/' . $reviews['langimg'])

//tep_output_string_protected($reviews['langname'])

); ?></td>

                    <td class="smallText" align="right"><?php echo sprintf(TEXT_REVIEW_DATE_ADDED, tep_date_short($reviews['date_added'])); ?></td>

                  </tr>

 

That's it!

A nice note, featuring the flag of the language, appears above the review.

 

SGershon

 

PS> Let me know if something is wrong. In my store its working, but maybe I forgot a step or a line when posting.

If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...