Search code examples
magentomodulemagento2

How to show custom checkout filed in admin panel


How to display custom column in the admin panel.

Tables sales_order, quote, column name gst.

I want to display a column in the sale order.

Code details

click here

enter image description here


Solution

  • You can override the adminhtml template file "order/view/info.phtml" and add the code to display your GST below billing address section. Refer below code sample.

    app/code/Company/Module/view/adminhtml/layout/sales_order_view.xml

    <?xml version="1.0"?>
    <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_info">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">Company_Module::order/view/info.phtml</argument>
                </action>
            </referenceBlock>
        </body>
    </page>
    

    Add below code to your info.phtml to the section below billing address (DON'T REPLACE THE ENTIRE CONTENT).

    app/code/Company/Module/view/adminhtml/templates/order/view/info.phtml

    <?php echo $block->getOrder()->getGst();?>