【发布时间】:2018-11-29 08:40:34
【问题描述】:
我们如何将销售订单历史记录内容添加到客户帐户中。
向sales_order_history 页面添加列的方法有哪些?无需编辑
view/frontend/templates/order/history.phtml
可以帮帮我吗?
【问题讨论】:
标签: magento2 add account customer
我们如何将销售订单历史记录内容添加到客户帐户中。
向sales_order_history 页面添加列的方法有哪些?无需编辑
view/frontend/templates/order/history.phtml
可以帮帮我吗?
【问题讨论】:
标签: magento2 add account customer
您无需触摸 view/frontend/templates/order/history.phtml 模板文件即可在客户销售订单历史记录页面中添加额外的列。 p>
将布局 view/frontend/layout/sales_order_history.xml 复制到您的主题中,并将附加列标题添加到 sales.order.history.extra .column.header 使用 sales.order.history.extra.container 块阻止和呈现列数据。
现在一切就绪。
【讨论】:
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<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 class="Magento\Framework\View\Element\Template" name="your.additional.column.header" template="Namespace_Module::columnheader.phtml"/>
</referenceBlock>
<!-- You can access current order using $this->getOrder() inside the template ">
<referenceBlock name="sales.order.history.extra.container">
<block class="Magento\Framework\View\Element\Template" name="your.additional.column.data" template="Namespace_Module::columndata.phtml"/>
</referenceBlock>
</body>
</page>
【讨论】:
我有一个更简单、更短的解决方案(示例中的日期列):
1- 在您的主题/扩展中创建布局文件夹-> sales_order_history.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="sales.order.history.extra.container" template="Magento_Sales::order/date/data.phtml"/>
</body>
</page>
2-为templates/date/data.phtml中的数据创建模板并复制:
<?php
/* @var $block \Magento\Sales\Block\Order\History\Container */
?>
<td data-th="<?= $block->escapeHtml(__('Date')) ?>" class="col date">
<?= $block->escapeHtml($block->getOrder()->getCreatedAt()) ?></td>
【讨论】: