2

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?

2 Answers 2

3

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.

https://www.ecomextension.com/order-comment.html

0

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();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.