How to display custom checkout field value in Admin Sales Order?

Adding Template File

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="LearningRewriteSalesBlockAdminhtmlOrderViewCustom" name="sales_order_view_custom" template="order/view/custom.phtml" />
    </referenceBlock>
  </body>
</page>

Other Method

Learning/RewriteSales/Block/Adminhtml/Order/View/Custom.php

<?php
namespace LearningRewriteSalesBlockAdminhtmlOrderView;
class Custom extends MagentoBackendBlockTemplate
{

}

Learning/RewriteSales/view/adminhtml/layout/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="LearningRewriteSalesBlockAdminhtmlOrderViewCustom" name="sales_order_view_custom" template="order/view/custom.phtml" />
    </referenceBlock>
  </body>
</page>
Learning/RewriteSales/view/adminhtml/templates/order/view/custom.phtml

<h1>Hi, I am here!</h1>

clear the cache and run it.

Leave a comment

Your email address will not be published. Required fields are marked *