Magento 2 offers a “My Account” section for the customers to check their details like account details, order and payment details, shipment, taxes, etc.
It is always a good practice for online stores to deliver maximum information to the customers about their orders, payments, shipping, etc.
With online shopping, until the customers do not get their items in hand, the urge to know about their order increases. The “My Account” section in Magento 2 store answers such customers’ questions.
Now, every business is different and has unique requirements. So, if you need to display any additional order details, you can do so with the below method to add column to customer sales order history page in Magento 2.
Here’s an example where “Customer Note” column is added and the sales order history page is customized for the same:
Magento 2 Add Column to Customer Sales Order History Page
- Create a file at path app/code/Vendor/Module/view/frontend/layout/sales_order_history.xml123456789101112<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"><body><!-- This will add additional column header to order list --><referenceBlock name="sales.order.history.extra.column.header"><block name="vendor.additional.column.header" template="Vendor_Module::extraColumn-header.phtml"/></referenceBlock><!-- You can access current order using $this->getOrder() inside the template "--><referenceBlock name="sales.order.history.extra.container"><block name="vendor.additional.column.data" template="Vendor_Module::extraColumn.phtml"/></referenceBlock></body>
- Create template file at path app/code/Vendor/Module/view/frontend/templates/extraColumn-header.phtml123456<?php/* @var $block \Magento\Sales\Block\Order\History\Container */?><th data-th="<?= $block->escapeHtml(__('Customer Note')) ?>" class="col"><?= $block->escapeHtml("Customer Note") ?></th>
- Create template file at path app/code/Vendor/Module/view/frontend/templates/extraColumn.phtml1234567<?php/* @var $block \Magento\Sales\Block\Order\History\Container */?><td data-th="<?= $block->escapeHtml(__('Customer Note')) ?>" class="col"><?= $block->escapeHtml($block->getOrder()->getCustomerNote()) ?></td>
By following the above method, you can easily add column to sales order history page (FO) in Magento 2. Any doubts in the solution can be mentioned in the Comments section below. I’d be happy to help.
Also, do share the solution with fellow Magento developers via social media.
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.