{"id":1568,"date":"2021-02-15T12:26:45","date_gmt":"2021-02-15T12:26:45","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/add-custom-message-to-admin-sales-order-view-invoice-credit-memo-in-magento-2\/"},"modified":"2025-07-17T17:43:08","modified_gmt":"2025-07-17T12:13:08","slug":"add-custom-message-to-admin-sales-order-view-invoice-credit-memo-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/add-custom-message-to-admin-sales-order-view-invoice-credit-memo-in-magento-2\/","title":{"rendered":"How to Add Custom Message to Admin Sales Order View, Invoice, and Credit Memo in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">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!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Default&nbsp;Magento 2&nbsp;provides a user-friendly interface and customization facility for the admin to address their requirements efficiently.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Store admins tend to improve their stores\u2019 admin panel by customizing admin functionalities, adding custom messages, columns, adding filters or removing them in the grid, etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One such example that I have mentioned here is to&nbsp;add custom message to admin sales order view, invoice, and credit memo in Magento 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, you may want to display a custom message when an order contains gift while processing that order from the admin panel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check out the below solution for implementing such examples in your store:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Add Custom Message to Admin Sales Order View, Invoice, and Credit Memo in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1:<\/strong> Create layout files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Method to add a custom message to admin sales order view<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/02\/order-view.png\" alt=\"How to Add Custom Message to Admin Sales Order View, Invoice, and Credit Memo in Magento 2\" class=\"wp-image-13086\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Create&nbsp;<strong>sales_order_view.xml&nbsp;<\/strong>at&nbsp;<strong>Vendor\/Module\/view\/adminhtml\/layout\/<\/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;referenceBlock name=\"order_info\">\n            &lt;block class=\"Vendor\\Module\\Block\\Adminhtml\\Order\\View\\CustomMessage\" name=\"sales_order_view_custom_msg\"\n                   template=\"order\/view\/customMessage.phtml\"\/>\n        &lt;\/referenceBlock>\n    &lt;\/body>\n&lt;\/page><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Method to add a custom message to the invoice<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/02\/Invoice.png\" alt=\"How to Add Custom Message to Admin Sales Order View, Invoice, and Credit Memo in Magento 2\" class=\"wp-image-13085\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Create&nbsp;<strong>sales_order_invoice.xml&nbsp;<\/strong>at&nbsp;<strong>Vendor\/Module\/view\/adminhtml\/layout\/<\/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\"\n      xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\">\n    &lt;body>\n        &lt;referenceBlock name=\"order_info\">\n            &lt;block class=\"Vendor\\Module\\Block\\Adminhtml\\Order\\View\\CustomMessage\" name=\"invoice_view_custom_msg\"\n                   template=\"order\/view\/customMessage.phtml\"\/>\n        &lt;\/referenceBlock>\n    &lt;\/body>\n&lt;\/page><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. Method to add a custom message to the credit memo<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/02\/Credit-memo.png\" alt=\"How to Add Custom Message to Admin Sales Order View, Invoice, and Credit Memo in Magento 2\" class=\"wp-image-13087\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Create&nbsp;<strong>sales_order_creditmemo.xml&nbsp;<\/strong>at&nbsp;<strong>Vendor\/Module\/view\/adminhtml\/layout\/<\/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\"\n      xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\">\n    &lt;body>\n        &lt;referenceBlock name=\"order_info\">\n            &lt;block class=\"Vendor\\Module\\Block\\Adminhtml\\Order\\View\\CustomMessage\" name=\"credirmemo_view_custom_msg\"\n                   template=\"order\/view\/customMessage.phtml\"\/>\n        &lt;\/referenceBlock>\n    &lt;\/body>\n&lt;\/page><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2: <\/strong>Now, create&nbsp;<strong>customMessage.php<\/strong>&nbsp;at&nbsp;<strong>Vendor\/Module\/Block\/Adminhtml\/Order\/View\/<\/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 customMessage extends \\Magento\\Backend\\Block\\Template\n{\n    \/\/ Here you can fetch order detail if you want to display in order information as an extra detail\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 3: <\/strong>Create&nbsp;<strong>customMessage.phtml<\/strong>&nbsp;at&nbsp;<strong>Vendor\/Module\/view\/adminhtml\/templates\/order\/view<\/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;h3>This order contains gift&lt;\/h3><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s all!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In case you want to change the whole layout of the backend, you can add a&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/add-custom-phtml-file-in-magento-2-admin\/\" target=\"_blank\" rel=\"noreferrer noopener\">custom Phtml file in Magento 2 admin panel<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Learn More &#8211; <a href=\"https:\/\/meetanshi.com\/blog\/add-custom-block-in-admin-sales-order-view-in-magento-2\/\" data-type=\"link\" data-id=\"https:\/\/meetanshi.com\/blog\/add-custom-block-in-admin-sales-order-view-in-magento-2\/\">Add Custom Block in Admin Sales Order View in Magento 2<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to share the solution with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank You.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#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-1568","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1568","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=1568"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1568\/revisions"}],"predecessor-version":[{"id":16890,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1568\/revisions\/16890"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}