How to add a new section to the Magento 2 admin sales order view

Blog
Spread the love

The Sales Order View is a page in the Magento admin panel that displays all the information related to a specific sales order. This page provides a detailed overview of the order, including customer information, order status, shipping and billing addresses, payment method, order items, prices, discounts, and taxes. Learn how to add sections to the Magento 2 sale order view page in this article. Depending on the goals of each individual, each component will have a unique custom function. A module called “Bluethinkinc_CustomSection” contains code.

1. Add a button

We’ll start by learning how to include a top button in the order view.

A plugin that targets “beforeSetLayout” is used first. As demonstrated below, add the following “type” node to your module’s “app/code/Bluethinkinc/CustomSection/etc/adminhtml/di.xml” file.

Step 2: Define button attributes

To add a button and its attributes, create a button class.

Add the subsequent code to the “app/code/Bluethinkinc/CustomSection/Plugin/Sales/Block/Adminhtml/Order/Button.php

Here, we’ve defined a button that, when pressed by the user, sends a signal via its own ID, name, and route

Result

View an order from the backend and clear the layout cache. The “Custom Button” button element has been made, as you can see:

attributes_create_img

2. Add a custom tab

To add a custom tab on the Sales Order View page in Magento 2, you can follow these steps:

The sales order view.xml file will be first created with the following content and placed in the app/code/Bluethinkinc/view/adminhtml/layout directory.

We created a new tab on the left-hand menu in this file, complete with a name and the block class that is in charge of it.

Step 2: Define block class

We’ll build a class called CustomTab inside app/code/Bluethinkinc/CustomSection/Block/Admin/Order/View/Tab:

In order to add information to the custom tab, we will finally create the template file.

The left panel now includes our new tab, as shown below:

includes_new_tab_img

3. Add a custom block to order view information

Step 1 : Define a custom block in the layout XML in step 1.

The sales order view.xml file in the app/code/Bluethinkinc/CustomSection/view/adminhtml/layout directory must first have the following code included.

The order block for the Additional Information will contain our custom block.

Step 2: Define block class

The View.php file will then be created and placed in the location app/code/Bluethinkinc/CustomSection/Block/Adminhtml/Order/View.

Step 3: Define view template

The block’s content is then created in the view.phtml file, which is the last step.

When you click to view any order after clearing the cache, you will see that 1 block has been inserted as the red cavity below.

handling_info_img

We trust you may find this article to be useful.

Thanks for reading!

bluethinkinc_blog

bluethinkinc_blog

2023-03-29

0

Leave a Reply

Your email address will not be published. Required fields are marked *

Find More Blogs

Customize lead qualification for a seamless experience

Spread the love When the 2024 Release Wave 2 was launched,

Create a Custom Console Command in Spryker

Spread the love In Spryker, developers can create custom

SALESFORCE

Spread the love Salesforce is a cloud-based software

CRUD Operation in Spryker Backoffice with a Custom Module

Spread the love Spryker is a highly flexible and modular

How to create custom module on Spryker for Backoffice?

Spread the love Creating a custom module in Spryker

How to Install Spryker Project with Docker on Local Machine

Spread the love Spryker is a flexible and scalable commerce

How to Add a Custom Tab to the Customer Order Detail Page in Magento 2

Spread the love Adding a custom tab to the Order Detail

Exception Handling in Java

Spread the love Introduction – Exception:An unwanted

How to add custom less file in Magento2

Spread the love Source files *.css included into layout

Spring Boot Microservices

Spread the love Microservices architecture has become

bluethinkinc Blogs