2014-09-21 36 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