I have created my own function which is trigged for the event sales_order_status_history_save_after. What I wanted to do is, when a new comment is added, the system will get the latest order comment, and send it to customer.
I have tried using the following code,
public function CommentSaveAfter()
{
$history = $order->getStatusHistoryCollection()->getFirstItem();
return $history->getComment();
}
However, this code only get me the last comment before the new one is added.
See screenshot, the code only get the last comment 4444, not 5555 when I click on "Submit Comment"
How can I get the latest comment when click on Submit Comment with event sales_order_status_history_save_after ?
This question is not duplicated with Magento event for adding order comment
My problem is I can not get the comment I just added to the order comment, but only the latest comment from status_history. I have already managed to add my own function to the event sales_order_status_history_save_after. So it's different from the other question.