Adding Customer Comments as Order Status Comments using Magento & OneStepCheckout
A few days ago I got an email from someone asking me about adding the default customer comments in OneStepCheckout (www.onestepcheckout.com) as regular order comments. I thought I’d share this quick & simple hack with everyone, so here’s what you have to do:
Open app/code/local/Idev/OneStepCheckout/Helper/Data.php, and after
$observer->getEvent()->getOrder()->setOnestepcheckoutCustomercomment($orderComment);
add this line:
$observer->getEvent()->getOrder()->setState( Mage_Sales_Model_Order::STATE_NEW, true, $orderComment, false );
$observer->getEvent()->getOrder()->setState( $observer->getEvent()->getOrder()->getStatus(), true, $orderComment, false );
This will add the comments on the regular comments/statuses thread, as well as a customer comment. If you want to disable customer comments, just comment the original code.
Actually, this approach should also work with the out-of-the-box Magento one step checkout. Add an input on the last step, create a listener for
checkout_type_onepage_save_order
and use the same piece of code:
$observer->getEvent()->getOrder()->setState( $observer->getEvent()->getOrder()->getStatus(), true, $this->_getRequest()->getPost('order_comments'), false );
Note: Tested on Magento 1.4.1.0 & 1.4.1.1