Rafael Trigo
Rafael Trigo

Reputation: 15

How to show only reviews by current language in Opencart?

I need the visitor only see the reviews in current Language!

I'm new to Opencart, if a visitor chooses a language like English to navigate on the site, how to don't show up the comments in other languages ​​as Portuguese, Spanish, Italian etc.

Why? It doens't make sense to see the comments in a language that the visitor does not understand!

I think in create a dropdown available languages in the reviews tab, and the user "Must" choose his language , and then store in database, and show up only the reviews in the selected language with a php if ... anyone could help me, how can I do it in Opencart?

Upvotes: 1

Views: 681

Answers (2)

shadyyx
shadyyx

Reputation: 16065

You would have to follow these steps:

1. edit the review saving

  1. in the database You would have to add the language_id column into review table
  2. in catalog/model/catalog/review.php model edit the addReview() method - after date_added = NOW() in the SQL query add this: , language_id = and after the last " before ) add this: . (int)$this->config->get('config_language_id')
  3. by doing this You will be able to save the selected language of the reviewer with his review - please, be realize that the selected language (in OpenCart) may not be the same as the language in which the review is written...

2. edit the review loading

  1. We will only edit catalog/model/catalog/review.php now and will do the same change in both methods getReviewsByProductId and getTotalReviewsByProductId and to make this simple, add the new where condition directly after WHERE in the SQL queries: r.language_id = " . (int)$this->config->get('config_language_id') . " AND
  2. by doing this we make sure that only the reviews in the language user has currently selected are loaded (and their respective count is correct)

This should be it.

Upvotes: 1

Teddybugs
Teddybugs

Reputation: 1244

maybe this could help in quick:

http://www.gmodules.com/ig/creator?synd=open&url=http://www.google.com/ig/modules/translatemypage.xml&lang=en

otherwise modification to the opencart code are required,

1) determine the comment's language

2) session identify the user's language

3) compare if match or not

4) if match, show the comment

Upvotes: 0

Related Questions