Opencart + ajax = Forbidden 403?

Добавляю функцию отправки сообщения к опенкарту.

Обработка запроса:
$('.button-modal').live('click', function() {
	$.ajax({
		url: 'index.php?route=product/product/modal',
		type: 'post',
		data: $('.modal-form textarea[type=\'text\'], .modal-form input[type=\'text\'], .modal-form input[type=\'hidden\']'),
		dataType: 'json',
		beforeSend: function() {
			$('.button-modal').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
		},	
		complete: function() {
			$('.wait').remove();
		},			
		success: function(json) {
			$('.warning, .error').remove();
						
			if (json['error']) {
				if (json['error']['name']) {
					$('.modal-form input[name=\'name\']').after('<span class="error">' + json['error']['name'] + '</span>');
				}

				if (json['error']['email']) {
					$('.modal-form input[name=\'email\']').after('<span class="error">' + json['error']['email'] + '</span>');
				}
				
				if (json['error']['phone']) {
					$('.modal-form input[name=\'phone\']').after('<span class="error">' + json['error']['phone'] + '</span>');
				}
				
				if (json['error']['message']) {
					$('.modal-form textarea[type=\'text\']').after('<span class="error">' + json['error']['message'] + '</span>');
				}
																																				
			} else {
				$('.modal-form').html('Your message has been sent');
			}
			
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});	
});

php запись в product.php:
public function modal() {

		$json = array();

		if (!$json) {					
			if ((utf8_strlen($this->request->post['name']) < 1) || (utf8_strlen($this->request->post['name']) > 32)) {
				$json['error']['name'] = 'error name';
			}

			if ((utf8_strlen($this->request->post['email']) > 96) || !preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email'])) {
				$json['error']['email'] = 'error email';
			}
			
			if ((utf8_strlen($this->request->post['phone']) < 1) || (utf8_strlen($this->request->post['phone']) > 32)) {
				$json['error']['phone'] = 'error phone';
			}
			
			if ((utf8_strlen($this->request->post['message']) < 1) || (utf8_strlen($this->request->post['message']) > 32)) {
				$json['error']['message'] = 'error message';
			}
		}

		if (!$json) {
			$mail = new Mail();
			$mail->protocol = $this->config->get('config_mail_protocol');
			$mail->parameter = $this->config->get('config_mail_parameter');
			$mail->hostname = $this->config->get('config_smtp_host');
			$mail->username = $this->config->get('config_smtp_username');
			$mail->password = $this->config->get('config_smtp_password');
			$mail->port = $this->config->get('config_smtp_port');
			$mail->timeout = $this->config->get('config_smtp_timeout');				
			$mail->setTo($this->config->get('config_email'));
			$mail->setFrom($this->request->post['email']);
			$mail->setSender($this->request->post['name']);
			$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
			$mail->setText(strip_tags(html_entity_decode('Имя:' . $this->request->post['name']. '/r/n Телефон:' . $this->request->post['phone']. '/r/n E-mail:' . $this->request->post['email']. '/r/n Сообщение:' . $this->request->post['message']. '/r/n Сообщение отправлено со страницы:' . $this->request->post['page'], ENT_QUOTES, 'UTF-8')));
			$mail->send();
			$json['success'] = 'OK';

		}	

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


На что мне ответ Forbidden 403
Остальные запросы к серверу работают адекватно (родные запросы)
Где мой косяк?
  • Вопрос задан
  • 746 просмотров
Пригласить эксперта
Ответы на вопрос 1
Код в методе modal() не проверял, но если там все верно, то почистите кэш опенкарта и vqmod, посмотрите htaccess (мало ли, может там были какие-то изменения внесены, но вряд ли), в крайнемм случае перезапустите сервер. Должно работать, я подобным образом писал модуль быстрого заказа в свое время, только в отдельном контроллере.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы