Magento添加现有评论以订购电子邮件

时间:2012-09-20 10:32:35

标签: php mysql magento

我已经安装了iwd_onepagecheckout extension

客户可以在订单中添加评论。

现在我想将此“评论”添加到订单电子邮件中。评论将保存在表sales_flat_order_status_history中,其中包含以下列:

  

entity_id,parent_id,is_customer_notified,is_visible_on_front,comment,status,created_at,entity_name

我搜索了论坛,但无法找到如何做到这一点。

2 个答案:

答案 0 :(得分:1)

我解决了!

来自onepagecheckout扩展名的observer.php:

public function addHistoryComment($data)
{
$comment    = Mage::getSingleton('customer/session')->getOrderCustomerComment();
$comment    = trim($comment); 
    if (!empty($comment))
    {
    $data['order']->addStatusHistoryComment($comment)->setIsVisibleOnFront(true)->setIsCustomerNotified(false);
    $order = $data->getEvent()->getOrder(); 
    $order->setCustomerComment($comment);
    $order->setCustomerNoteNotify(true);
    $order->setCustomerNote($comment);
    }
}

答案 1 :(得分:1)

上面的答案是正确的。但是,它会复制管理面板中的注释。您有一次评论而不通知客户,第二次通知客户。

您需要评论或删除第$data['order']->addStatusHistoryComment($comment)->setIsVisibleOnFront(true)->setIsCustomerNotified(false);行,因为这会将评论添加到管理端的订单页面,但不会通知客户。

所以最终的脚本应该是:

public function addHistoryComment($data)
{
    $comment    = Mage::getSingleton('customer/session')->getOrderCustomerComment();
    $comment    = trim($comment); 
    if (!empty($comment))
    {
        $order = $data->getEvent()->getOrder(); 
        $order->setCustomerComment($comment);
        $order->setCustomerNoteNotify(true);
        $order->setCustomerNote($comment);
    }
}