If you want to add a new button on the sales order view page in the admin side then you have to do that by the plugin.
Please follow the below steps.
Step 1: Create a di.xml file on the below path and paste the below code in it.
Path: app/code/Magemonkeys/CustomOrderButton/etc/adminhtml/di.xml
1 2 3 4 5 6 7 |
<?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\Button\Toolbar"> <plugin name="add_custom_button_toolbar" type="Magemonkeys\CustomOrderButton\Plugin\CustomButtonPlugin" /> </type> </config> |
Step 2: Create the plugin file on the below path and paste the below code in it.
Path: app/code/Magemonkeys/CustomOrderButton/Plugin/CustomButtonPlugin.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<?php declare(strict_types=1); namespace Magemonkeys\CustomOrderButton\Plugin; use Magento\Sales\Block\Adminhtml\Order\Create; use Magento\Framework\View\Element\AbstractBlock; use Magento\Backend\Block\Widget\Button\ButtonList; use Magento\Backend\Block\Widget\Button\Toolbar as ToolbarContext; class CustomButtonPlugin { public function beforePushButtons(ToolbarContext $toolbar,AbstractBlock $context,ButtonList $buttonList): array { $orderObject = false; $layoutName = $context->getNameInLayout(); if ('sales_order_edit' == $layoutName) { $orderObject = $context->getOrder(); } if ($orderObject) { $url = 'My Custom URL' $buttonList->add('custom_btn',['label' => __('Custom Button'),'on_click' => sprintf("location.href = '%s';", $url),'class' => 'primary custom_button','id' => 'custom_btn']); } return [$context, $buttonList]; } } ?> |
[crayon-63d3ee0314242356288531/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.