31 lines
765 B
PHP
31 lines
765 B
PHP
|
|
<?php
|
||
|
|
namespace Shopkeeper\OrderItemsCustom\Plugin\Order\View;
|
||
|
|
|
||
|
|
class ItemsColumns
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Modify the columns array to remove tax columns and add cost column
|
||
|
|
*
|
||
|
|
* @param \Magento\Sales\Block\Adminhtml\Order\View\Items $subject
|
||
|
|
* @param array $result
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
public function afterGetColumns($subject, $result)
|
||
|
|
{
|
||
|
|
// Remove tax columns
|
||
|
|
unset($result['tax-amount']);
|
||
|
|
unset($result['tax-percent']);
|
||
|
|
|
||
|
|
// Add cost column after price
|
||
|
|
$newColumns = [];
|
||
|
|
foreach ($result as $key => $value) {
|
||
|
|
$newColumns[$key] = $value;
|
||
|
|
if ($key === 'price') {
|
||
|
|
$newColumns['cost'] = 'Cost';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return $newColumns;
|
||
|
|
}
|
||
|
|
}
|