我在网址链接结帐/购物车中有此表单,在此页面中,我有一个表单,其中包含您的姓名的以下文本框,您的电子邮件,您的电话号码,您对公司和截止日期项目的评论。在这种形式下,它运作良好,数据将发送到电子邮件。我希望您的评论数据将发送到销售/订单中的管理面板。这是app/design/adminhtml/default/default/template/sales/order/view
info.phtml文件的路径。
我找到了一个示例代码并使用它。并且我发现我看起来的示例代码没有成功。这是我正在使用的参考链接
http://www.magecorner.com/magento-order-comments/
答案 0 :(得分:0)
您可以使用活动尝试此操作。将以下代码添加到config.xml中。我希望你有一个处理观察者和事件的想法。
<events>
<sales_order_place_after> <!-- identifier of the event we want to catch -->
<observers>
<sales_order_place_after_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>orderaudit/observer</class> <!-- observers class alias -->
<method>orderPlaced</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</sales_order_place_after_handler>
</observers>
</sales_order_place_after>
<sales_order_payment_capture> <!-- identifier of the event we want to catch -->
<observers>
<sales_order_payment_capture_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>orderaudit/observer</class> <!-- observers class alias -->
<method>paymentCapture</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</sales_order_payment_capture_handler>
</observers>
</sales_order_payment_capture>
<sales_order_creditmemo_refund> <!-- identifier of the event we want to catch -->
<observers>
<sales_order_creditmemo_refund_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>orderaudit/observer</class> <!-- observers class alias -->
<method>creditmemoRefund</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</sales_order_creditmemo_refund_handler>
</observers>
</sales_order_creditmemo_refund>
</events>
第2步:现在将以下内容添加到Observer.php
public function orderPlaced(Varien_Event_Observer $observer)
{
if (Mage::getSingleton('admin/session')->isLoggedIn()) {
//if admin
$order = $observer->getEvent()->getOrder();
$user = Mage::getSingleton('admin/session');
$username = $user->getUser()->getUsername();
$comment = "Order placed by <strong>".$username."</strong>";
$order->addStatusHistoryComment($comment)
->setIsVisibleOnFront(false)
->setIsCustomerNotified(false);
$order->save();
}
else {
//placed by customer online
$order = $observer->getEvent()->getOrder();
$order->addStatusHistoryComment('Order placed online by customer')
->setIsVisibleOnFront(false)
->setIsCustomerNotified(false);
$order->save();
}
}
public function paymentCapture(Varien_Event_Observer $observer)
{
$invoice = $observer->getEvent()->getInvoice();
$order = $invoice->getOrder();
$user = Mage::getSingleton('admin/session');
$username = $user->getUser()->getUsername();
$comment = "Payment captured by <strong>".$username."</strong>";
$order->addStatusHistoryComment($comment)
->setIsVisibleOnFront(false)
->setIsCustomerNotified(false);
$order->save();
}
public function creditmemoRefund(Varien_Event_Observer $observer)
{
$creditmemo = $observer->getEvent()->getCreditmemo();
$order = $creditmemo->getOrder();
$user = Mage::getSingleton('admin/session');
$username = $user->getUser()->getUsername();
$comment = "Refund by <strong>".$username."</strong>";
$order->addStatusHistoryComment($comment)
->setIsVisibleOnFront(false)
->setIsCustomerNotified(false);
$order->save();
}
}