OpenCart 🇺🇦

Схема

public mixed write ( )

Аргументы

Аргумент Возможный тип Описание
У метода нет аргументов

Описание

Метод пока еще не документирован.

Исходный код

$this->language->load('product/product');

$this->load->model('catalog/review');

$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'])) {
		$json['error'] = $this->language->get('error_rating');
	}

	if (empty($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
		$json['error'] = $this->language->get('error_captcha');
	}

	if (!isset($json['error'])) {
		$this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post);

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

$this->response->setOutput(json_encode($json));