11

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?

Alin Lupoiu
  • 2,662
  • 5
  • 40
  • 76

1 Answers1

10

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();
}
Moose
  • 7,495
  • 7
  • 48
  • 91