SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH
speed-up-image-website
speed-up-image-website

Add content to Order View Magento 2

Add content to Magento 2 Admin page; specifically the “Order and Account” section of the Information page in “Order View”.

In this article, we will learn how to add sections to the sale order view page in Magento 2. Each component will have its own custom function depending on the purpose of each person. We will introduce several ways to add a new element to the order view, code snippets are under a module named ‘Magepow_RewriteSales’.

  1. Magepow/RewriteSales/Block/Adminhtml/Order/View/Custom.php
<?php
namespace Magepow\RewriteSales\Block\Adminhtml\Order\View;
class Custom extends \Magento\Backend\Block\Template
{

}

2. Magepow/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="Magepow\RewriteSales\Block\Adminhtml\Order\View\Custom" name="sales_order_view_custom" template="order/view/custom.phtml" />
        </referenceBlock>
    </body>
</page>

3. Magepow/RewriteSales/view/adminhtml/templates/order/view/custom.phtml

<h1>Our Adiitional Block</h1>

Run command

php bin/magento setup:uppgrade

php bin/magento s:s:d -f

php bin/magento cache:flush

4. Result

We hope that this article will be helpful to you.

Thanks for reading!