How to Display Custom Checkout Field Value in Admin Sales Order in Magento 2

custom-attributesmagento2sales-order

I have creat a custom module that adds a custom field to checkout. It is the input text field. I save this value to quote table and to the sales_order table. But now I want to display this value in admin panel Sales->Order, under Shipping Method information. How can I do this?

Thanks in advance for all the tips.

Best Answer

you can achieve this by adding your template file to sales_order_view.xml ,

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>      
        <referenceBlock name="order_info">
            <block class="Learning\RewriteSales\Block\Adminhtml\Order\View\Custom" name="sales_order_view_custom" template="order/view/custom.phtml" />
        </referenceBlock>
    </body>
</page>

and in your template file you can get the relevant information . for this you have to create 1.one block 'Learning\RewriteSales\Block\Adminhtml\Order\View\Custom' 2.one template 'order/view/custom.phtml' 3.and the changes to sales_order_view.xml as mentioned above ,

for more information you can refer this link enter link description here

if you face any problem , let me know , i will help :)