2

I have two custom fields in sales_order_item table. Now i want to show that two fields in sales order item section. I tried this solution. But it is always adding new column at the end.

So, how i can add my custom column after Item status and also should be editable? Like attached example.

enter image description here

1
  • Can you share your custom module, how you achieved this? Commented Jan 7, 2024 at 12:12

1 Answer 1

2

Finally i found the solution. Using this code i am able to arrange columns as per my requirement.

<referenceBlock name='order_tab_info'> <block class="Magento\Sales\Block\Adminhtml\Order\View\Items" name="order_items" template="Magento_Sales::order/view/items.phtml"> <arguments> <argument name="columns" xsi:type="array"> <item name="sku" xsi:type="string" translate="true">SKU</item> <item name="product" xsi:type="string" translate="true">Product</item> <item name="status" xsi:type="string" translate="true">Item Status</item> <item name="product-cost" xsi:type="string" translate="true">Product Cost</item> <item name="ship-cost" xsi:type="string" translate="true">Ship Cost</item> <!-- <item name="price-original" xsi:type="string" translate="true">Original Price</item> --> <item name="price" xsi:type="string" translate="true">Price</item> <item name="ordered-qty" xsi:type="string" translate="true">Qty</item> <item name="subtotal" xsi:type="string" translate="true">Subtotal</item> <item name="tax-amount" xsi:type="string" translate="true">Tax Amount</item> <item name="tax-percent" xsi:type="string" translate="true">Tax Percent</item> <item name="discont" xsi:type="string" translate="true">Discount Amount</item> <item name="total" xsi:type="string" translate="true">Row Total</item> </argument> </arguments> <block class="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" as="default" name="default_order_items_renderer" template="Magento_Sales::order/view/items/renderer/default.phtml"> <arguments> <argument name="columns" xsi:type="array"> <item name="sku" xsi:type="string" translate="false">col-sku</item> <item name="product" xsi:type="string" translate="false">col-product</item> <item name="status" xsi:type="string" translate="false">col-status</item> <item name="product-cost" xsi:type="string" translate="false">col-product-cost</item> <item name="ship-cost" xsi:type="string" translate="false">col-ship-cost</item> <!-- <item name="price-original" xsi:type="string" translate="false">col-price-original</item> --> <item name="price" xsi:type="string" translate="false">col-price</item> <item name="qty" xsi:type="string" translate="false">col-ordered-qty</item> <item name="subtotal" xsi:type="string" translate="false">col-subtotal</item> <item name="tax-amount" xsi:type="string" translate="false">col-tax-amount</item> <item name="tax-percent" xsi:type="string" translate="false">col-tax-percent</item> <item name="discont" xsi:type="string" translate="false">col-discont</item> <item name="total" xsi:type="string" translate="false">col-total</item> </argument> </arguments> </block> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="Magento_Sales::items/column/qty.phtml" group="column"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name" name="column_name" template="Magento_Sales::items/column/name.phtml" group="column"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="column_sku" template="HK_CustomField::items/column/sku.phtml" group="column"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="column_product-cost" template="HK_CustomField::items/column/product_cost.phtml" group="column" /> <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="column_ship-cost" template="HK_CustomField::items/column/ship_cost.phtml" group="column" /> <block class="Magento\Framework\View\Element\Text\ListText" name="order_item_extra_info"/> </block> </referenceBlock> 
1
  • This is not working for me I did the same you did. where did you define the button? Commented Mar 6, 2021 at 22:03

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.