Отзывы: Убрать имя,отзыв и модерацию. Оставить только оценку товара.

Тема в разделе "Общие вопросы", создана пользователем gegshsitr, 30 янв 2021.

  1. gegshsitr

    gegshsitr Новичок

    Сообщения:
    3
    Симпатии:
    0
    sos.jpg Помогите в отзывах в карточке товара убрать ИМЯ и САМ отзыв и модерацию, а оставить только оценку товара. Очень долго не могу решить свою проблему. Спасите. (Opencart3).
     
  2. fanatic

    fanatic Продвинутый пользователь

    Сообщения:
    1.415
    Симпатии:
    239
    шаблон product.twig
    HTML:
    {% if review_status %}
        <div class="tab-pane" id="tab-review">
            <form class="form-horizontal" id="form-review">
                {#    <div id="review"></div>
                  <h2>{{ text_write }}</h2> #}
                {% if review_guest %}
                    {# <div class="form-group required">
                       <div class="col-sm-12">
                         <label class="control-label" for="input-name">{{ entry_name }}</label>
                         <input type="text" name="name" value="{{ customer_name }}" id="input-name" class="form-control" />
                       </div>
                     </div>
                     <div class="form-group required">
                       <div class="col-sm-12">
                         <label class="control-label" for="input-review">{{ entry_review }}</label>
                         <textarea name="text" rows="5" id="input-review" class="form-control"></textarea>
                         <div class="help-block">{{ text_note }}</div>
                       </div>
                     </div> #}
                    <div class="form-group required">
                        <div class="col-sm-12">
                            <label class="control-label">{{ entry_rating }}</label>
                            &nbsp;&nbsp;&nbsp; {{ entry_bad }}&nbsp;
                            <input type="radio" name="rating" value="1" />
                            &nbsp;
                            <input type="radio" name="rating" value="2" />
                            &nbsp;
                            <input type="radio" name="rating" value="3" />
                            &nbsp;
                            <input type="radio" name="rating" value="4" />
                            &nbsp;
                            <input type="radio" name="rating" value="5" />
                            &nbsp;{{ entry_good }}</div>
                    </div>
                    {{ captcha }}
                    <div class="buttons clearfix">
                        <div class="pull-right">
                            <button type="button" id="button-review" data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ button_continue }}</button>
                        </div>
                    </div>
                {% else %}
                    {{ text_login }}
                {% endif %}
            </form>
        </div>
    {% endif %}
    контроллер product.php
    PHP:
        public function write() {
            
    $this->load->language('product/product');

            
    $json = array();

            if (
    $this->request->server['REQUEST_METHOD'] == 'POST') {
    //            if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) {
    //                $json['error'] = $this->language->get('error_name');
    //            }
    //
    //            if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) {
    //                $json['error'] = $this->language->get('error_text');
    //            }

                
    if (empty($this->request->post['rating']) || $this->request->post['rating'] < || $this->request->post['rating'] > 5) {
                    
    $json['error'] = $this->language->get('error_rating');
                }

                
    // Captcha
                
    if ($this->config->get('captcha_' $this->config->get('config_captcha') . '_status') && in_array('review', (array) $this->config->get('config_captcha_page'))) {
                    
    $captcha $this->load->controller('extension/captcha/' $this->config->get('config_captcha') . '/validate');

                    if (
    $captcha) {
                        
    $json['error'] = $captcha;
                    }
                }

                if (!isset(
    $json['error'])) {
                    
    $this->load->model('catalog/review');
                    
    // это добавили
                    
    $this->request->post['name'] = '';
                    
    $this->request->post['text'] = '';
                    
    // end
                    
    $this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post);

                    
    $json['success'] = $this->language->get('text_success');
                }
            }

            
    $this->response->addHeader('Content-Type: application/json');
            
    $this->response->setOutput(json_encode($json));
        }
    модель (review.php) добавляем statuls = 1
    PHP:
    public function addReview($product_id$data) {
            
    $this->db->query("INSERT INTO " DB_PREFIX "review SET author = '" $this->db->escape($data['name']) . "', customer_id = '" . (int) $this->customer->getId() . "', product_id = '" . (int) $product_id "', text = '" $this->db->escape($data['text']) . "', rating = '" . (int) $data['rating'] . "', date_added = NOW(), status = 1");
     
  3. gegshsitr

    gegshsitr Новичок

    Сообщения:
    3
    Симпатии:
    0
    Сделал всё. Рухнуло всё.:):rolleyes:
     
  4. fanatic

    fanatic Продвинутый пользователь

    Сообщения:
    1.415
    Симпатии:
    239
    что\ как сделали?
    способ. рабочий, проверено
     
  5. gegshsitr

    gegshsitr Новичок

    Сообщения:
    3
    Симпатии:
    0
    Видимо не всё понял.
    1ую часть вставил из админки в product.twig

    2 часть не знал куда девать и вставлял поочерёдно-
    -../public_html/catalog/controller/product/product.php
    ../public_html/admin/controller/catalog/product.php
    ../storage.1595787092/modification/catalog/controller/product/product.php

    3 часть вставил ./public_html/catalog/model/catalog |review.php

    Лучшее что у меня получилось исчезли " ВАши отзывы" и "Ваше имя". "Оценка -" улетела и стала над фото товара. Из админки при входе Каталог-товар сразу всё слетает.
    Ну ничего (не страшно пробовал на черновом сайте). Все равно спасибо за мучения. Всех благ.
     
  6. fanatic

    fanatic Продвинутый пользователь

    Сообщения:
    1.415
    Симпатии:
    239
    копипаст тут не пройдет
    мой код не нужно было вставлять
    я выложил оригинальный код с закоментированным и добавленным кодом
    вам, нужно найти у себя данные коды, и изменить как в моем примере.