🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Add Custom Block in Admin Sales Order View in Magento 2

By Sanjay JethvaUpdated on May 22, 2025 3 min read

The default Magento 2 displays the address information, payment, and shipping information, etc. on the admin sales order view.

However, sometimes it may not be enough based on the business requirements.

Therefore, one needs to add custom block in admin sales order view in Magento 2.

For example, you are offering customized products and the customers add instructions for their personalization. To display those instruction texts in the admin sales order view, you can use the below solution.

Also Read: Add a Row Count to The Order Sales View Items Table in Magento 2.4

Or, if you are an Indian store, you may display GST information in the sales order view.

Display any custom block based on your business requirements as shown in the below figure:

Add Custom Block in Admin Sales Order View in Magento 2

Steps to add custom block to admin sales order view in Magento 2:

1. Create registration.php file at app\code\Vendor\Module directory

<?php
use \Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Vendor_Module', __DIR__);

2. Create module.xml file at app\code\Vendor\Module\etc directory

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="1.0.0"/>
</config>

3. Create sales_order_view.xml file at app\code\Vendor\Module\view\adminhtml\layout

<?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>
        <!--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"/>
        </referenceBlock>
    </body>
</page>

4. Create block file View.php in Vendor\Module\Block\Adminhtml\Order\View

<?php
namespace Vendor\Module\Block\Adminhtml\Order\View;
class View extends \Magento\Backend\Block\Template
{
    public function myFunction()
    {
        //your code
        return "Customers' Instruction";
    }
}

5. Create view.phtml in Vendor\Module\view\adminhtml\templates\order\view

<div>
    <h1><?php echo $block->myFunction()?></h1>
    <h3>I want two different sizes, i.e., M and XL for the customized tshirts ordered here. Also, I want to increase the
        font size of the text to 25.</h3></br>
    <h3>Thank you.</h3>
</div>

That’s it.

You can also add a custom Phtml in Magento 2 admin to change the complete layout.

Also, do share the solution with the Magento Community via social media.

Thank you.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.