Magento 1.9 Orders – Automatically Add Comment on Order Placement

backendcheckoutcustomermagento-1.9orders

I have the following situation:

I am on the checkout page, and i have 3 Shipping methods.
If i select a specific method form all 3 and i finish the order, i want a comment to be added automatically on the orders view from backend in this area:

enter image description here

Does anyone have any idea how can i do this?

Best Answer

You'll want to create an event-observer module & observe sales_order_place_after.

Your observer method would look like this:

public function logShipping($observer){
    $order = $observer->getEvent()->getOrder();
    $history = $order->addStatusHistoryComment($order->getShippingMethod(), false);
    $history->setIsCustomerNotified(false);
    $order->save();
}
Related Topic