Magento 2 store admins not only strive to make their store convenient to customers but also continuously implement various tactics to make the store convenient for themselves!
Default Magento 2 provides a user-friendly interface and customization facility for the admin to address their requirements efficiently.
Store admins tend to improve their stores’ admin panel by customizing admin functionalities, adding custom messages, columns, adding filters or removing them in the grid, etc.
One such example that I have mentioned here is to add custom message to admin sales order view, invoice, and credit memo in Magento 2.
For example, you may want to display a custom message when an order contains gift while processing that order from the admin panel.
Check out the below solution for implementing such examples in your store:
Steps to Add Custom Message to Admin Sales Order View, Invoice, and Credit Memo in Magento 2
Step 1: Create layout files.
1. Method to add a custom message to admin sales order view

Create sales_order_view.xml at 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>
<referenceBlock name="order_info">
<block class="Vendor\Module\Block\Adminhtml\Order\View\CustomMessage" name="sales_order_view_custom_msg"
template="order/view/customMessage.phtml"/>
</referenceBlock>
</body>
</page>
2. Method to add a custom message to the invoice

Create sales_order_invoice.xml at Vendor/Module/view/adminhtml/layout/
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="order_info">
<block class="Vendor\Module\Block\Adminhtml\Order\View\CustomMessage" name="invoice_view_custom_msg"
template="order/view/customMessage.phtml"/>
</referenceBlock>
</body>
</page>
3. Method to add a custom message to the credit memo

Create sales_order_creditmemo.xml at Vendor/Module/view/adminhtml/layout/
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="order_info">
<block class="Vendor\Module\Block\Adminhtml\Order\View\CustomMessage" name="credirmemo_view_custom_msg"
template="order/view/customMessage.phtml"/>
</referenceBlock>
</body>
</page>
Step 2: Now, create customMessage.php at Vendor/Module/Block/Adminhtml/Order/View/
<?php
namespace Vendor\Module\Block\Adminhtml\Order\View;
class customMessage extends \Magento\Backend\Block\Template
{
// Here you can fetch order detail if you want to display in order information as an extra detail
}
Step 3: Create customMessage.phtml at Vendor/Module/view/adminhtml/templates/order/view
<h3>This order contains gift</h3>
That’s all!
In case you want to change the whole layout of the backend, you can add a custom Phtml file in Magento 2 admin panel.
Learn More – Add Custom Block in Admin Sales Order View in Magento 2
Feel free to share the solution with Magento Community via social media.
Thank You.