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

Proxy Design Pattern and Requisition List in Magento 2

Spread the love Requisition List in Magento 2 Requisition

Google Ads Conversion Tracking Through Magento Platform:

Spread the love Google Ads Conversion Tracking Through

Object Pool Pattern in Magento2

Spread the love What is Object Pool Pattern in Magento 2 An

JENKINS

Spread the love JENKINS Introduction and Installation

Virtual Type and Type

Spread the love Virtual type is one of the most common

Customize the length of Input field

Spread the love Sometimes we need to change the limit the

How to Add Custom Tab on Admin Dashboard and Count Website Total Visitor in Magento 2?

Spread the love In this blog we’ll see How to Add Custom

How to Add Sign Out Tab in Customer Account in Magento 2?

Spread the love In this blog we’ll see How to Add

How to create custom tab in product detail page in magento 2?

Spread the love In this blog we’ll see how to add

Understanding and Implementing CORS & CSRF

Spread the love What is security? The world has become more

bluethinkinc Blogs