在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!

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.