未定义的索引(opencart) [英] undefined index (opencart)

查看:96
本文介绍了未定义的索引(opencart)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在opencart中添加新的输入文本, 我的视图 payment_method.tpl 我添加了

I'm trying to add a new input text in opencart, my view payment_method.tpl I added

<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 中,我添加了

In Controller payment_method.tpl I added

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

In My model 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

我收集的视图中的任何内容都不会发布到我的控制器中,但是我不确定我还能在何处定义Refered. 我认为使用OC时,在视图中定义的内容都会发布到控制器上?

I gather whatever is on my view isn't being posted to my controller, however I'm not sure where else I can define referred. I thought with OC whatever is defined inside the view, it's posted to the controller?

有人请帮助

预先感谢

推荐答案

这里的问题很明显.新的 referred 输入未通过HTTP AJAX请求传递.这是由另一个模板-checkout.tpl引起的.打开它,滚动到末尾并搜索此JS回调:

The problem here is obvious. The new referred input is not passed via HTTP AJAX request. This is caused in a different template - checkout.tpl. Open it up, scroll to the end and search for this JS callback:

$('#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索引设置.

Now the value should be passed via AJAX request and should be set for the referred indexes.

这篇关于未定义的索引(opencart)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆