Showing results for 
Search instead for 
Did you mean: 

Add and save custom field on order view page

Add and save custom field on order view page



How can I add a new input field on order view page - something similar to the 'comments section'.

Purpose I need it is to save some code reference into it for some orders.

I need it for admin only, so this is NOT a checkout field, and I ant to be able to show it under sales grid columns as well, and further edit from sale view page.


Any idea appreciated!



Re: Add and save custom field on order view page


Decide a section where you want to add a custom field
and edit it based on your requirement.
For example:
Add the below code in app\code\Vendor\Module\view\adminhtml\layout\sales_order_view.xml
<?xml version="1.0"?>
<page xmlns:xsi="" layout="admin-2columns-left"
        <!--add custom block -->
        <referenceBlock name="order_additional_info">
            <block class="Vendor\Module\Block\Adminhtml\Order\View\View" name="custom_view" template="order/view/view.phtml"/>
Add the below code in app\code\Vendor\Module\Block\Adminhtml\Order\View\View.php
namespace Vendor\Module\Block\Adminhtml\Order\View\;
class View extends \Magento\Backend\Block\Template
    public function myFunction()
        //your code
        return "Customers' Instruction";
Add the below code in 
    <h1><?php echo $block->myFunction()?></h1>
    <h3>Thank you.</h3>
Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

Re: Add and save custom field on order view page

Well, what I find most difficult is that i need it to be an editable field which should be saved from the order view page. Displaying it inside a block wherever it's not the biggest challenge.