Jump to content
Sign in to follow this  
fatalex

Добавление новых полей во вкладке запроса

Recommended Posts

Здравствуйте уважаемые форумчане.

Продолжаю осваивать opencart. И вот появился ещё один вопрос.

Есть вкладка запроса в карточке товара. Имелись поля имя, email, text_area... Вот добавил поле для ввода телефона и столкнулся с тем, что значение этого поля не прилетает на e-mail, с остальными полями всё вроде норм.

Вроде и в контроллер всё добавил и в папке language поля дописал, ну и в product.tpl соответственно переменные ввёл. Но на email по-прежнему значения из этого поля не прилетают.

Подскажите пожалуйста, что ещё проверить, в какую сторону копать.

 

Share this post


Link to post
Share on other sites

Есть вкладка запроса в карточке товара.

 

Что это?

Share this post


Link to post
Share on other sites

По сути вторая форма обратной связи с отсылкой на почту админа.

Сейчас выкину листинг

product.php

$this->data['tab_question'] = $this->language->get('tab_question');
$this->data['text_ask'] = $this->language->get('text_ask');
$this->data['entry_name_ask'] = $this->language->get('entry_name_ask');
$this->data['entry_email_ask'] = $this->language->get('entry_email_ask');
$this->data['entry_phone_ask'] = $this->language->get('entry_phone_ask');
$this->data['error_phone_ask'] = $this->language->get('error_phone_ask');
$this->data['entry_question_ask'] = $this->language->get('entry_question_ask');
 
public function write1() {
$this->language->load('product/product');
 
$this->load->model('catalog/askquestion');
 
$json = array();
 
if ((utf8_strlen($this->request->post['name1']) < 3) || (utf8_strlen($this->request->post['name1']) > 25)) {
$json['error'] = $this->language->get('error_name_ask');
}
 
if ((utf8_strlen($this->request->post['phone']) < 6)) {
$json['error'] = $this->language->get('error_phone_ask');
}
 
if ((utf8_strlen($this->request->post['email']) < 6) || (utf8_strlen($this->request->post['email']) > 35)) {
$json['error'] = $this->language->get('error_email_ask');
}
 
if ((utf8_strlen($this->request->post['text1']) < 15) || (utf8_strlen($this->request->post['text1']) > 1000)) {
$json['error'] = $this->language->get('error_text_ask');
}
 
if (!isset($this->session->data['captcha1']) || ($this->session->data['captcha1'] != $this->request->post['captcha1'])) {
$json['error'] = $this->language->get('error_captcha_ask');
}
 
if (($this->request->server['REQUEST_METHOD'] == 'POST') && !isset($json['error'])) {
$this->model_catalog_askquestion->addAskquestion($this->request->get['product_id'], $this->request->post);
 
$json['success'] = $this->language->get('text_success_ask');
}
 
$this->response->setOutput(json_encode($json));
}
 
public function captcha1() {
$this->load->library('captcha1');
 
$captcha1 = new Captcha1();
 
$this->session->data['captcha1'] = $captcha1->getCode();
 
$captcha1->showImage();
}
 
 
public function captcha() {
$this->load->library('captcha');
 
$captcha = new Captcha();
 
$this->session->data['captcha'] = $captcha->getCode();
 
$captcha->showImage();
}
 
public function upload() {
$this->language->load('product/product');
 
$json = array();
 
if (!empty($this->request->files['file']['name'])) {
$filename = basename(preg_replace('/[^a-zA-Z0-9\.\-\s+]/', '', html_entity_decode($this->request->files['file']['name'], ENT_QUOTES, 'UTF-8')));
 
if ((strlen($filename) < 3) || (strlen($filename) > 64)) {
        $json['error'] = $this->language->get('error_filename');
  }  
 
$allowed = array();
 
$filetypes = explode(',', $this->config->get('config_upload_allowed'));
 
foreach ($filetypes as $filetype) {
$allowed[] = trim($filetype);
}
 
if (!in_array(substr(strrchr($filename, '.'), 1), $allowed)) {
$json['error'] = $this->language->get('error_filetype');
        }
 
if ($this->request->files['file']['error'] != UPLOAD_ERR_OK) {
$json['error'] = $this->language->get('error_upload_' . $this->request->files['file']['error']);
}
} else {
$json['error'] = $this->language->get('error_upload');
 
 

product.tpl

 <div id="tab-askquestion" class="tab-content" style="border: 1px solid #000;">
    <div id="askquestion"></div>
    <h2 id="askquestion-title" style="text-transform:none;"><?php echo $text_ask; ?> <?php echo $model; ?> </h2>
<br />
    <img src="./image/name.png" align="absmiddle" /> <b><?php echo $entry_name_ask; ?></b><br />
    <input type="text" name="name1" value="" />
    <br />
<br />
    <img src="./image/phone.png" align="absmiddle" /> <b><?php echo $entry_phone_ask; ?></b><br />
    <input type="text" name="phone" value="" />
    <br />
<br />
<img src="./image/email.png" align="absmiddle" /> <b><?php echo $entry_email_ask; ?></b><br />
    <input type="text" name="email" value="" />
    <br />
    <br />
    <img src="./image/question.png" align="absmiddle" /> <b><?php echo $entry_question_ask; ?></b>
    <textarea name="text1" cols="40" rows="8" style="width: 98%;"></textarea>
    <br />
    <br />
    <b><?php echo $entry_captcha; ?></b><br />
    <input type="text" name="captcha1" value="" />
    <br />
    <img src="index.php?route=product/product/captcha1" alt="" id="captcha1" /><br />
    <br />
    <div class="buttons">
      <div class="right"><a id="button-askquestion" class="button"><span><?php echo $button_continue; ?></span></a></div>
    </div>
  </div>
 
<script type="text/javascript">
$('#button-askquestion').bind('click', function() {
$.ajax({
type: 'POST',
url: 'index.php?route=product/product/write1&product_id=<?php echo $product_id; ?>',
dataType: 'json',
data: 'name1=' + encodeURIComponent($('input[name=\'name1\']').val()) + '&email=' + encodeURIComponent($('input[name=\'email\']').val()) + '&phone=' + encodeURIComponent($('input[name=\'phone\']').val()) + '&text1=' + encodeURIComponent($('textarea[name=\'text1\']').val()) + '&captcha1=' + encodeURIComponent($('input[name=\'captcha1\']').val()),
beforeSend: function() {
$('.success, .warning').remove();
$('#button-askquestion').attr('disabled', true);
$('#askquestion-title').after('<div class="attention"><img src="catalog/view/theme/default/image/loading.gif" alt="" /> <?php echo $text_wait; ?></div>');
},
complete: function() {
$('#button-askquestion').attr('disabled', false);
$('.attention').remove();
},
success: function(data) {
if (data.error) {
$('#askquestion-title').after('<div class="warning">' + data.error + '</div>');
}
 
if (data.success) {
$('#askquestion-title').after('<div class="success">' + data.success + '</div>');
 
$('input[name=\'name1\']').val('');
$('input[name=\'email\']').val('');
$('input[name=\'phone\']').val('');
$('textarea[name=\'text1\']').val('');
$('input[name=\'captcha1\']').val('');
}
}
});
});
</script>
 
В файле на который ссылается контроллер, сейчас следующее
ask_question.php
<?php
class ModelCatalogAskquestion extends Model {
public function addAskquestion($product_id, $data) {
 
$this->load->model('catalog/product');
$product_info = $this->model_catalog_product->getProduct($product_id);
$message ='<b>Product:</b> <a href="'.($this->url->link('product/product', '&product_id=' . $this->request->get['product_id'])).'">'.(strip_tags($product_info['name'])).'</a><br />';
$message.='<b>Name:</b> '.(strip_tags($data['name1'])).'<br />';
$message.='<b>Email:</b> '.(strip_tags($data['email'])).'<br /><br />';
$message.='<b>Question:</b> <br />';
$message.=(strip_tags($data['text1']))."<br /><br />";
$mail = new Mail($this->config->get('config_mail_protocol'),
$this->config->get('config_smtp_host'),
$this->config->get('config_smtp_username'),
html_entity_decode($this->config->get('config_smtp_password')),
$this->config->get('config_smtp_port'),
$this->config->get('config_smtp_timeout'));
$mail->setTo(array($this->config->get('config_email')));
$mail->setFrom(strip_tags($data['email']));
$mail->setSender(strip_tags($data['name1']));
$mail->setSender(strip_tags($data['phone']));
$mail->setSubject((strip_tags($data['name1'])). ' wants to ask you something about ' .(strip_tags($product_info['name'])));
$mail->setHtml($message);
$mail->send();
}
}
?>
Где еще можно порыть поискать причину.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.