{"id":1417,"date":"2020-11-21T07:11:31","date_gmt":"2020-11-21T07:11:31","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/add-custom-block-in-admin-sales-order-view-in-magento-2\/"},"modified":"2025-07-17T10:27:13","modified_gmt":"2025-07-17T04:57:13","slug":"add-custom-block-in-admin-sales-order-view-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/add-custom-block-in-admin-sales-order-view-in-magento-2\/","title":{"rendered":"How to Add Custom Block in Admin Sales Order View in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The default\u00a0Magento 2\u00a0displays the address information, payment, and shipping information, etc. on the admin sales order view.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, sometimes it may not be enough based on the business requirements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Therefore, one needs to&nbsp;<em><strong>add custom block in admin sales order view in Magento 2<\/strong><\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Also Read:<\/strong>&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/add-a-row-count-to-the-order-sales-view-items-table-in-magento-2-4\/\">Add a Row Count to The Order Sales View Items Table in Magento 2.4<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Or, if you are an Indian store, you may display GST information in the sales order view.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Display any custom block based on your business requirements as shown in the below figure:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/11\/Add-Custom-Block-in-Admin-Sales-Order-View-in-Magento-2-1024x481.png\" alt=\"Add Custom Block in Admin Sales Order View in Magento 2\" class=\"wp-image-11601\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to add custom block to admin sales order view in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create&nbsp;<em><strong>registration.php<\/strong><\/em>&nbsp;file at&nbsp;<strong><strong>app\\code\\Vendor\\Module<\/strong><\/strong>&nbsp;directory<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nuse \\Magento\\Framework\\Component\\ComponentRegistrar;\nComponentRegistrar::register(ComponentRegistrar::MODULE, 'Vendor_Module', __DIR__);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create&nbsp;<em><strong>module.xml<\/strong><\/em>&nbsp;file at&nbsp;<strong><strong>app\\code\\Vendor\\Module\\etc<\/strong><\/strong>&nbsp;directory<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n        xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Module\/etc\/module.xsd\">\n    &lt;module name=\"Vendor_Module\" setup_version=\"1.0.0\"\/>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. Create&nbsp;<em><strong>sales_order_view.xml<\/strong><\/em>&nbsp;file at&nbsp;<strong><strong>app\\code\\Vendor\\Module\\view\\adminhtml\\layout<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" layout=\"admin-2columns-left\"\n      xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\">\n    &lt;body>\n        &lt;!--add custom block -->\n        &lt;referenceBlock name=\"order_additional_info\">\n            &lt;block class=\"Vendor\\Module\\Block\\Adminhtml\\Order\\View\\View\" name=\"custom_view\" template=\"order\/view\/view.phtml\"\/>\n        &lt;\/referenceBlock>\n    &lt;\/body>\n&lt;\/page><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">4. Create block file&nbsp;<em><strong>View.php<\/strong><\/em>&nbsp;in&nbsp;<strong><strong><strong><strong>Vendor\\Module\\Block\\Adminhtml\\Order\\View<\/strong><\/strong><\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nnamespace Vendor\\Module\\Block\\Adminhtml\\Order\\View;\nclass View extends \\Magento\\Backend\\Block\\Template\n{\n    public function myFunction()\n    {\n        \/\/your code\n        return \"Customers' Instruction\";\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">5. Create&nbsp;<em><strong>view.phtml<\/strong><\/em>&nbsp;in&nbsp;<strong><strong><strong><strong>Vendor\\Module\\view\\adminhtml\\templates\\order\\view<\/strong><\/strong><\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;div>\n    &lt;h1>&lt;?php echo $block->myFunction()?>&lt;\/h1>\n    &lt;h3>I want two different sizes, i.e., M and XL for the customized tshirts ordered here. Also, I want to increase the\n        font size of the text to 25.&lt;\/h3>&lt;\/br>\n    &lt;h3>Thank you.&lt;\/h3>\n&lt;\/div><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/add-custom-phtml-file-in-magento-2-admin\/\" target=\"_blank\" rel=\"noreferrer noopener\">add a custom Phtml in Magento 2 admin<\/a>&nbsp;to change the complete layout.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, do share the solution with the Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The default\u00a0Magento 2\u00a0displays the address information, payment, and shipping information, etc. on the admin sales order view. However, sometimes it may not be enough based&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1417","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1417","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1417"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1417\/revisions"}],"predecessor-version":[{"id":14617,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1417\/revisions\/14617"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}