How do i add a extra form field in checkout page under delevery method section ?
Is there any possible option for that without installing any extension.
Thanks
You would either need to purchase a mod that allows you to do this, or modify the system yourself.
If you're going to modify the system yourself, you will need to start by adding a new column to the order table in the database. This is where your new field information will be stored.
You would then need to edit your files to add the new field, as well as save the data of this field. To do this, edit the following files:
catalog/view/theme/default/template/checkout/shipping_method.tpl
This is where you would add the new field.
catalog/controller/checkout/shipping_method.php
This is where you would capture the value that the customer has added. You would then save this value as a session variable similar to how the comment is saved.
Within the function "save" you would need to save your field data. Find:
Add After:
catalog/controller/checkout/confirm.php
Send this field data to the add order function so that it's saved to the database
Find:
Add After:
catalog/model/checkout/order.php
Within the addOrder function, you need to push your new field data to the database.
Find:
Add After Inline:
This should be enough to capture the information. You would still need to modify your admin panel to display this new field on the orders detail page.
Please note that I have not tested any of the code examples above.
Cheers,
Joel.
If you're going to modify the system yourself, you will need to start by adding a new column to the order table in the database. This is where your new field information will be stored.
You would then need to edit your files to add the new field, as well as save the data of this field. To do this, edit the following files:
catalog/view/theme/default/template/checkout/shipping_method.tpl
This is where you would add the new field.
Code: Select all
<input type="text" name="your_field" value="<?php echo $your_field; ?>" class="form-control" />
This is where you would capture the value that the customer has added. You would then save this value as a session variable similar to how the comment is saved.
Code: Select all
if (isset($this->session->data['your_field'])) {
$data['your_field'] = $this->session->data['your_field'];
} else {
$data['your_field'] = '';
}
Code: Select all
$this->session->data['comment'] = strip_tags($this->request->post['comment']);
Code: Select all
$this->session->data['your_field'] = strip_tags($this->request->post['your_field']);
Send this field data to the add order function so that it's saved to the database
Find:
Code: Select all
$order_data['comment'] = $this->session->data['comment'];
Code: Select all
$order_data['your_field'] = $this->session->data['your_field'];
Within the addOrder function, you need to push your new field data to the database.
Find:
Code: Select all
, comment = '" . $this->db->escape($data['comment']) . "'
Code: Select all
, your_field = '" . $this->db->escape($data['your_field']) . "'
Please note that I have not tested any of the code examples above.
Cheers,
Joel.
I followed the same procedure but i am getting error of json unidentified index "your_field" in the line $this->session->data['your_field'] = strip_tags($this->request->post['your_field'])]; in the controller/checkout/payment_method.php file. please guide me.
i apply this method with opencart 3 the unique diference is the view file, in version 3 is a twig file and not a tpl file.
but i have one problem. the form shows the fields, but this fields are not saved into the database. the problem is that they are not added to the array
can you help me please?
but i have one problem. the form shows the fields, but this fields are not saved into the database. the problem is that they are not added to the array
can you help me please?
Hello everyone,
I managed to eliminate all the steps related to shipping since my company coordinates it separately directly with the client but in the payment methods I added two input so that the user can also indicate if he is going to agree on a shipment later or if he is going to withdraw in store as to anticipate that management. In this case instead of editing on the "shipping_method.php" I had to do on the "payment_method.php" in the same way that is described here and it worked perfectly.
This post was very useful for me and I wanted to give the credit to "OpenCart Addons" for its careful response.
I managed to eliminate all the steps related to shipping since my company coordinates it separately directly with the client but in the payment methods I added two input so that the user can also indicate if he is going to agree on a shipment later or if he is going to withdraw in store as to anticipate that management. In this case instead of editing on the "shipping_method.php" I had to do on the "payment_method.php" in the same way that is described here and it worked perfectly.
This post was very useful for me and I wanted to give the credit to "OpenCart Addons" for its careful response.
I managed to get this working on adding an additional form field on payment_address.tpl and it is working well. A few minor changes but thanks for a very helpful article. I spent two days trying to get it to work before I found this.
All credit to the author.
v2.3.0.2
All credit to the author.
v2.3.0.2
Who is online
Users browsing this forum: No registered users and 15 guests