2025-10-21 14:55:37 -04:00
|
|
|
<?php
|
2025-11-11 09:06:37 -05:00
|
|
|
namespace Shopkeeper\AdminOrderColumns\Plugin\Order\View;
|
2025-10-21 14:55:37 -04:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|