0

Is there any way to add a button and column at the backend order view items renderer? I have tried multiples solution but did not work.

sales_order_view

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <body>
    <referenceBlock name="order_items">
        <arguments>
            <argument name="columns" xsi:type="array">
                <item name="inventory_source" xsi:type="string" translate="true">Source</item>
            </argument>
        </arguments>
        <referenceBlock name="default_order_items_renderer">
            <arguments>
                <argument name="columns" xsi:type="array">
                    <item name="inventory_source" xsi:type="string" translate="true">col-source</item>
                </argument>
            </arguments>
        </referenceBlock>

        <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="inventory_source"
               template="Test_DropShipping::order/items/source.phtml" group="column"/>
    </referenceBlock>
</body>

phtml file:

<?= $block->escapeHtml(__('Link to Product')) ?>
<?php if ($_item = $block->getItem()): ?>
<div class="product-source">
    <?= $block->escapeHtml(__('Link to Product')) ?>
</div>

enter image description here

0

1.Create file in app/code/[Vendor]/[Modulename]/view/adminhtml/layout/sales_order_view.xml

<page xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:noNamespaceSchemaLocation=""urn:magento:framework:View/Layout/etc/page_configuration.xsd"">
    <body>
        <referenceBlock name=""order_items"">
            <arguments>
                <argument name=""columns"" xsi:type=""array"">
                    <item name=""custom_item_column"" xsi:type=""string"" translate=""true"">Custom Item Column</item>
                </argument>
            </arguments>
            <referenceBlock name=""default_order_items_renderer"">
                <arguments>
                    <argument name=""columns"" xsi:type=""array"">
                        <item name=""custom_item_column"" xsi:type=""string"" translate=""true"">col-custom_item_column</item>
                    </argument>
                </arguments>
            </referenceBlock>

            <block class=""Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn""
                   name=""column_custom_item_column""
                   template=""Smartosc_Sales::custom_item_column.phtml"" group=""column"" />
        </referenceBlock>
    </body>
</page>

2.Create file [Namespace]/[Modulename]/view/adminhtml/templates/custom_item_column.phtml folder and add the below code.

<?= __($block->getItem()->getData('custom_item_column')) ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.