2014-09-21 115 views
0

我想加入Opencart的新的输入文字, 我看来payment_method.tpl我加未定义指数(Opencart的)

<label><?php echo $text_comments; ?></label> 
<textarea name="comment" rows="8" style="width: 98%;"><?php echo $comment; ?></textarea> 

<label><?php echo $text_referred; ?></label> // My Code 
<input type="text" name="referred" value="<?php echo $referred; ?>" /> 

在控制器payment_method.tpl我加入

if (!$json) { 
       $this->session->data['payment_method'] = $this->session->data['payment_methods'][$this->request->post['payment_method']]; 
       $this->session->data['comment'] = strip_tags($this->request->post['comment']); 
       $this->session->data['referred'] = $this->request->post['referred']; //My Code 
      } 

if (isset($this->session->data['referred'])) { 
      $this->data['referred'] = $this->session->data['referred']; //Variable 
     } else { 
      $this->data['referred'] = ''; 
     } 

在我的模型Order.php

$this->db->query("INSERT INTO `" . DB_PREFIX . "order` SET invoice_prefix = '" . $this->db->escape($data['invoice_prefix']) . "', referred = '" . $this->db->escape($data['referred']) . "', 

我的错误日志显示

2014-09-21 12:57:42 - PHP Notice: Undefined index: referred in /home/dlars/public_html/tempdir/vqmod/vqcache/vq2-catalog_controller_checkout_payment_method.php on line 212 
2014-09-21 12:57:42 - PHP Notice: Undefined index: referred in /home/dlars/public_html/tempdir/vqmod/vqcache/vq2-catalog_model_checkout_order.php on line 4 

我收集无论是在我的观点没有被贴到我的控制器,但是我不确定我可以定义的其他位置。 我认为与OC无论是在视图内定义,它张贴到控制器?

有人请帮助

在此先感谢

回答

0

这里的问题是显而易见的。新的参考输入不通过HTTP AJAX请求传递。这是由不同的模板引起的 - checkout.tpl。打开它,滚动到最后,搜索这个JS回调:

$('#button-payment-method').live('click', function() { 

这里找到行

data: $('#payment-method input[type=\'radio\']:checked, #payment-method input[type=\'checkbox\']:checked, #payment-method textarea'), 

并将其更改为:

data: $('#payment-method input[type=\'radio\']:checked, #payment-method input[type=\'checkbox\']:checked, #payment-method textarea, #payment-method input[type=\'text\']'), 

现在值应为通过AJAX请求传递,应该设置为referred索引。

+0

不错!环顾四周,并没有提及任何地方 – user2015172 2014-09-28 09:14:37