How To

MAGENTO 2: How to Change Default Active Tab on Admin Order View Page

Hello Magento Folks?,

Howā€™s everything going on? Welcome back to the How-To series where I am going to help you all in solving Magento 2: How to change active tabs on the admin order view page with its codes. Donā€™t forget to go through the most recent blog published for learning How to Add Available Quantity Per Product in The Catalog On Magento 2.3

Introduction:

As we all knowĀ  Magento 2 provides order information in order to view a page on the admin side. Here mainly, Magento 2 distinguishes order information in different parts for e.g. order basic information, order invoices, order shipments, order credit memo, etc. And for that Magento 2 creates some tabs to differentiate order information and from all of them there is one tab known as ā€œInformationā€, and this is by default active tab. But if we require to select any other tab as by default tab and not the ā€œInformationā€. No Worries, the given below code of solution will help you to change the default active tab as per your requirement.

Steps to Code:

Step 1: First, we need to createĀ  di.xml file at the following path,

app\code\Vendor\Extension\etc and add the below code.

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

<type name="Magento\Backend\Block\Widget\Tabs">

Ā Ā Ā Ā Ā Ā Ā Ā <plugin name="change_tab_selection_block" type="Vendor\Extension\Plugin\Block\Widget\Tabs" sortOrder="10" />

Ā Ā Ā Ā </type>

</config>

Step 2: After that, we need to create a Tabs.php file inside the below path.

app\code\Vendor\Extension\Plugin\Block\Widget and add below code

<?php

namespace Vendor\Extension\Plugin\Block\Widget;

class TabsĀ 

{

Ā Ā public function afterAddTab(\Magento\Backend\Block\Widget\Tabs $subject, $result)

Ā Ā {

Ā Ā Ā Ā Ā $subject->setActiveTab("order_history"); // you can set any tab name here

Ā Ā Ā Ā Ā return $result;

Ā Ā }

}

Step 3: Lastly, refresh the cache from the cache management option.

With the help of the above codes, you will be able to change the default tab to your required tab in Magento 2.

Over to You:

I hope there are no difficulties faced to you during the implementation of the above-given solution and in case any difficulties then feel free to contact our Support Team for further guidance. I hope the above solution helped if YES then do share with your Magento friends and also let us know your reviews regarding this solution in the comment section below.

Stay Home & Stay Safe ā€“ Happy Coding?

Click to rate this post!
[Total: 3 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate šŸŽ–ļø Certified Magento DeveloperšŸ‘Øā€šŸ’». He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fondā¤ļø of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.šŸ

Recent Posts

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

1 day ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

1 day ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

2 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

3 days ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

5 days ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

5 days ago