0

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?

0

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, privacy policy and cookie policy

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