1

To Disable/Remove “ship” Button from sales->order->view (click) -> Ship I commented in core file vendor\magento\module-sales\Block\Adminhtml\Order\View.php below code .

if ($this->_isAllowedAction(
       'Magento_Sales::ship'
) && $order->canShip() && !$order->getForcedShipmentWithInvoice()
) {
       $this->addButton(
            'order_ship',
            [
                 'label' => __('Ship'),
                 'onclick' => 'setLocation(\'' . $this->getShipUrl() . '\')',
                 'class' => 'ship'
            ]
       );
 }.

now how can i ovveride block to remove this function

2 Answers 2

0

Please try to create your custom module to override sales block. also, please check with below url which is very helpful to you how to override

https://webkul.com/blog/overriding-rewriting-classes-magento2/

and add block with extends

<?php
namespace Vendorname\Modulename\Block\Adminhtml\Order;
use Magento\Framework\View\Element\Template;
class View extends Magento\Sales\Block\Adminhtml\Order\View {

public function functionname()  // which have default in Magento\Sales\Block\Adminhtml\Order\View
{ 
return "Override Text"; 
}
}
2
  • please vote my question or answer .. I have less reputation score to ask important and complicated question.
    – irshad
    Commented Oct 5, 2019 at 7:21
  • thanks to you support ... please have a look this link if you submit your effort magento.stackexchange.com/questions/291115/…
    – irshad
    Commented Oct 5, 2019 at 7:39
0

To remove ship button in admin order view page

app/code/Vendor/Module/etc/adminhtml/di.xml

<?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="remove_ship_button" type="Vendor\Module\Plugin\RemoveButton" />
    </type>
</config>

app/code/Vendor/Module/Plugin/RemoveButton.php

<?php
namespace Vendor\Module\Plugin;

class RemoveButton
{
    public function beforePushButtons(
        \Magento\Backend\Block\Widget\Button\Toolbar\Interceptor $subject,
        \Magento\Framework\View\Element\AbstractBlock $context,
        \Magento\Backend\Block\Widget\Button\ButtonList $buttonList
    ) {

        $this->_request = $context->getRequest();
        if($this->_request->getFullActionName() == 'sales_order_view'){
            $buttonList->remove('order_ship');//Button id
        }
    }
}
6
  • di.xml will be in app/code/Vendor/Module/etc/di.xml...?
    – irshad
    Commented Oct 5, 2019 at 6:48
  • Yes.....It either be in any one folder... Commented Oct 5, 2019 at 6:49
  • it is area specific, you wanted to hide button in admin panel so I added di.xml in adminhtml area....If you add di.xml in etc folder it will take this as global area. So it will work both frontend and adminhtml. Commented Oct 5, 2019 at 6:51
  • thanks its work nicely
    – irshad
    Commented Oct 5, 2019 at 7:19
  • please have a look below link ... magento.stackexchange.com/questions/291115/…
    – irshad
    Commented Oct 5, 2019 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.