dongyin0628 2019-03-18 20:20
浏览 96

在Checkout中添加了自定义字段3 Checkout的第5步 - 未接收输入

I have added a custom text input field to the payment methods portion of OpenCart 3.0.3.1 checkout process. I know I'm missing something, because the order checkout process will complete, but it's passing the default value through for the custom field instead of the user input value.

The default value is set in the Save function for payment methods. Without setting it here, I get a json error that I don't know how else to get around.

I'm lost as to what I'm missing. Please, can someone tell me why the input value is being ignored?? What can I change to get the user input value to pass along with the rest of the order data?

My Twig code for text field, payment_method.php:

`<div class="form-group required">
 <label class="col-sm-2 control-label" for="input-ponumber">{{ entry_ponumber }}</label>
 <div class="col-sm-10">
 <input type="text" name="ponumber" id="ponumber" class="form-control" />
 </div> `

Added:

'#collapse-payment-method input[type=\'text\']:checked' 

to the Ajax script in checkout.twig to include text field:

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

Added ponumber codes to catalog/controller/checkout/payment_method.php:

In index function:

'if (empty($this->request->post['ponumber'])) {
$data['error_warning'] = sprintf($this->language->get('error_ponumber'), $this->url->link('checkout/checkout'));
} else {
$data['error_warning'] = '';
}

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

In Save function (otherwise I get a Json error - invalid index on ponumber):

'       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']);

        if (!empty($this->request->post['ponumber'])) {
            $this->session->data['ponumber'] = $this->request->post['ponumber'];
        } else {
            $this->session->data['ponumber'] = '911';
        }

    }'

Added ponumber to catalog/controller/checkout/confirm.php:

'$order_data['ponumber'] = $this->session->data['ponumber'];'

Added ponumber to the insert query in catalog/model/order.php:

'ponumber = '" . $this->db->escape($data['ponumber']) . "',' 

What did I miss? Why is the default 911 value of ponumber ending up in the database instead of the user input value? Please help.

Yes, I did search, and search, and search, and previous posts either did not help or remain unanswered. Any and all help appreciated! Thank you!

  • 写回答

1条回答 默认 最新

  • drgaeqdqiiyg14608 2019-04-09 21:03
    关注

    Well, posted this in multiple places and no one seems to be able to actually help.

    If anyone else is stuck on this and needs a custom field in their OpenCart 3.0 checkout process, like a Purchase Order#, check this out:

    https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=36216

    This developer is awesome! They created this for me, then modified it to show up in Step 5 and have a more standard "required" feel. If you need something similar, they are quick to respond too and very reasonable. Problem solved.

    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?