Initial
This commit is contained in:
30
Plugin/Order/View/ItemsColumns.php
Normal file
30
Plugin/Order/View/ItemsColumns.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user