0

I want to remove Column Action from orders grid if order have certain status, how can I accomplish such behavior?

enter image description here

Or if it will be easier I would be happy if I could delete this View hyperlink :)

Thanks in advance :)

Shoaib Munir
9,59210 gold badges54 silver badges109 bronze badges
asked May 20, 2018 at 22:11

1 Answer 1

0

You can hide the View action for a particular order status using a plugin.

Create following files

app/code/Venodr/Module/etc/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\Sales\Ui\Component\Listing\Column\ViewAction">
 <plugin name="order_grid_view_action" type="Vendor\Module\Plugin\Order\Grid\ViewAction" />
 </type>
</config>

app/code/Vendor/Module/Plugin/Order/Grid/ViewAction.php

<?php
namespace Vendor\Module\Plugin\Order\Grid;
class ViewAction
{
 public function afterPrepareDataSource(
 \Magento\Sales\Ui\Component\Listing\Column\ViewAction $subject,
 $result,
 array $dataSource
 ) {
 foreach ($result['data']['items'] as & $item) {
 // add your condition here
 if ($item['status'] != 'pending') { 
 $item['actions'] = null;
 }
 }
 return $result;
 }
}
answered May 21, 2018 at 6:26
1
  • Happy learning :) Commented Jul 11, 2018 at 13:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.