How can I add customer comment from checkout page using observer?
Customer comment is introduced from the block with a text area. When I create new order I need to add a comment to this order using sales_order_place_before event. How can I do this?
You can use the below code in your observer to add order comment:
$comment = "Comment to be added in the order";
$order->addStatusHistoryComment($comment)
->setIsVisibleOnFront(false)
->setIsCustomerNotified(false);
$order->save();
Or you can use below free extension you can use for adding order comments on the checkout page.
Check the code below for simple add customer comment to order via observer:
// get the last order
$lastOrderId = $this->_getOnepage()->getCheckout()->getLastOrderId();
$order = Mage::getModel('sales/order')->load($lastOrderId);
// Add the comment and save the order (last parameter will determine if comment will be sent to customer)
$order->addStatusHistoryComment('This comment is programatically added to last order in this Magento setup');
$order->save();