【问题标题】:Display Magento order comments in print.phtml (customers prinable order)在 print.phtml 中显示 Magento 订单注释(客户可打印订单)
【发布时间】:2012-02-13 15:56:29
【问题描述】:

只是想知道是否有人知道如何在客户可打印订单上显示 cmets - http://www.mydomain.com/sales/order/print/order_id/48/

我可以看到我需要编辑的文件是“/public_html/app/design/frontend/default/mytemplate/template/sales/order/print.phtml”,但我不确定我需要添加什么代码来显示厘米。

仅供参考:我们正在使用此扩展程序使订单 cmets 框显示在订单页面上 - http://www.magentocommerce.com/magento-connect/catalog/product/view/id/10860/。订单 cmets 已成功显示在订单电子邮件中,但我们还需要将它们显示在客户订单页面上。

提前感谢您的帮助:)

【问题讨论】:

  • 还应该补充一点,我们正在使用 Magento 1.6 社区;)
  • 你得到你需要的了吗? @MWD

标签: magento


【解决方案1】:

+1 for code_break,谁回答得很好。为了完整起见,这是我自己的版本:

$orders = Mage::getModel('sales/order')
    ->getCollection()
    ->addFieldToFilter('status',array('pending','processing'));

foreach ($orders as $order) {
    $orderComments = $order->getAllStatusHistory();

    foreach ($orderComments as $comment) {
        $body = $comment->getData('comment');
        if (strpos(strtolower($body),'some text') !== false) {
            // do something cool here...
        }
    }
}

随意使用。希望对您有所帮助。

【讨论】:

【解决方案2】:

上一篇文章使用了订单对象的 getVisibleStatusHistory 方法,但在订单上输入的第一条评论永远不可见。有几种方法可以获取状态历史并将其设置在订单对象中。

话虽如此,我们可能希望列出所有在前端标记为可见的 cmets 以及创建订单时输入的第一条评论。我已经用<p> 标记替换了您的格式。

<?php $_history = $order->getAllStatusHistory(); ?>
<?php $_buffer = array(); ?>
<?php $_i=1; ?>

<?php foreach ($_history as $_historyItem): ?>
    <?php // Ignore the visibility for the first comment ?>
    <?php if ( $_historyItem->getData('is_visible_on_front') == 1 || $_i == count($_history) ): ?>
        <?php $_buffer[] = $_historyItem->getData('comment'); ?>
    <?php endif; ?>
    <?php $_i++; ?>
<?php endforeach; ?>

<?php if ( count($_buffer) > 0 ): ?>
    <p><?php echo implode( $_buffer, '</p><p>' ); ?></p>
<?php endif ?>

【讨论】:

    【解决方案3】:

    当您特别要求来自 MageMaven OrderComment 的 oder 评论时,这将是最简单的解决方案:

    <p><?php echo nl2br($_order->getCustomerNote()); ?></p>
    

    【讨论】:

    【解决方案4】:

    嘿,试试添加这段代码,我没有测试过,但我觉得它对你有用:

    <?php $_history = $_order->getVisibleStatusHistory() ?>
                                                        <?php if (count($_history)): ?>
                                                        <div class="order-additional order-comments">
                                                            <dl class="order-about">
                                                                <?php foreach ($_history as $_historyItem): ?>
                                                                    <dd>
                                                                        <span class='lowcase'><?php echo $_historyItem->getComment()?></span>
                                                                    </dd>
                                                                <?php endforeach; ?>
                                                            </dl>
                                                        </div>
                                                        <?php endif?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      相关资源
      最近更新 更多