How to Rearrange Sales Order View in Magento 2 Adminhtml

adminhtmlmagento2orders

I want to rearrange the sections in the sales order view (which is displayed while viewing an order in admin page).

I tried to move the Items ordered section before Order & Account Information. To achieve this, I have added sales_order_view.xml in my backend theme in Magento_Sales/layout.

<page>
    <body>
        <move element="order_items" destination="order_tab_info" before="-"/>
    </body>
</page>

However, the sales order view stays unchanged. I also tried to remove the order_items block which did work.

Best Answer

You cannot able to move order_items through layout file. Since order_tab_info block not renders it's child blocks automatically. So even though moving the blocks inside the order_tab_info block from the layout results in the same structure.

To do so, override /vendor/magento/module-sales/view/adminhtml/templates/order/view/tab/info.phtml and move the items ordered block before Line no:19 <?php echo $block->getChildHtml('order_info') ?>

<section class="admin__page-section">
    <div class="admin__page-section-title">
        <span class="title"><?php /* @escapeNotVerified */ echo __('Items Ordered') ?></span>
    </div>
    <?php echo $block->getItemsHtml() ?>
</section>

Now the items ordered block will be loaded before Order information.

Related Topic