显示Magento的订单注释(客户prinable顺序)

问题描述:

只是想知道如果任何人有任何想法如何显示客户打印顺序评论 - http://www.mydomain.com/sales/order/print/order_id/48/显示Magento的订单注释(客户prinable顺序)

我可以看到,我需要修改的是“文件/public_html/app/design/frontend/default/mytemplate/template/sales/order/print.phtml“,但我不确定需要添加哪些代码才能显示评论。

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

感谢您的帮助提前:)

+0

还要补充一点,我们使用Magento的1.6社区;) – MWD 2012-02-13 16:00:10

嘿尝试添加该代码我还没有测试,但我有一种感觉它会为你工作:

<?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?> 
+0

我想你的代码片段可惜当时不工作:( – MWD 2012-02-14 13:10:38

最后的后使用的getVisibleStatusHistory方法的订单对象,但订单上输入的第一条评论永远不可见。有几种方法可以抓取状态历史记录并在顺序对象中设置它。

这就是说,我们可能想要列出所有标记为可见的注释以及订单创建时输入的第一条注释。我用<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 ?> 

对于code_break +1,他很好地回答了这个问题。这是我自己的版本完整性:

$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... 
     } 
    } 
} 

如你所愿使用。希望能帮助到你。

正如你所要求特别是从MageMaven OrderComment奥德评论这将是最简单的解决方案:

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

谢谢,这正是我正在寻找;) – 2014-09-19 12:34:50